mirror-in-a-can/ubuntu/ansible.yml

68 lines
1.9 KiB
YAML
Raw Permalink Normal View History

---
# it should be fair to assume that "hosts: all" will do the trick
- name: Prepare Ubuntu Environment
hosts: all
become: true
tasks:
- name: Correct GPT information
ansible.builtin.command: sgdisk /dev/vda -e && partprobe
- name: Stretch partition
register: parted
community.general.parted:
device: /dev/vda
number: 3
label: gpt
state: present
resize: true
part_end: "100%"
- name: Stretch LVM PV
ansible.builtin.command: pvresize /dev/vda3
- name: Stretch logical partition
community.general.lvol:
vg: ubuntu-vg
lv: ubuntu-lv
resizefs: true
size: 100%FREE
- name: Base system update
ansible.builtin.apt:
update_cache: true
name: "*"
state: latest
- name: Install mirroring packages
ansible.builtin.apt:
name:
- nginx
- debmirror
- rsync
- gnupg
- xz-utils
- name: Prepare mirror environment
hosts: all
become: true
vars_files:
- config.yml
tasks:
- name: Create directory tree
loop:
- /srv/mirror/ubuntu
- /srv/mirror/lanyard
- /srv/mirror/bin
ansible.builtin.file:
name: "{{ item }}"
state: directory
- name: Download GPG keys
ansible.builtin.command: gpg --no-default-keyring --keyring /srv/mirror/lanyard/trustedkeys.gpg --import /usr/share/keyrings/ubuntu-archive-keyring.gpg
- name: Configure debmirror sync
ansible.builtin.template:
src: debmirror.sh.j2
dest: /srv/mirror/bin/debmirror.sh
mode: "0755"
- name: Initial mirror sync (this can take a while!)
ansible.builtin.command: /srv/mirror/bin/debmirror.sh
- name: Crontab configuration
ansible.builtin.cron:
name: mirror-update
hour: 2
minute: 0
job: /srv/mirror/bin/debmirror.sh