blob: c23e075c45f6a5901e0b0410193dd1b22530f561 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
---
- name: "Set root partition paths"
ansible.builtin.set_fact:
configure_chroot_path: "{{ partition_root.mount_path }}"
# After giving up on fixing the ansible.builtin.pip directly
# Workaround ansible install not working without reinstalling and configuring pip externally
- name: "Install ansible"
ansible.builtin.include_tasks: "install-ansible.yml"
- name: "Run distro-configure playbooks on bootstrapped distro"
when: configure_playbook_dir is defined
block:
- name: "Archive playbook on controller"
become: false
community.general.archive:
path: "{{ configure_playbook_dir }}/*"
dest: "/tmp/ansible-distro-configure.tar.gz"
mode: "0644"
format: "gz"
force_archive: true
exclude_path:
- "{{ configure_playbook_dir }}/.git"
- "{{ configure_playbook_dir }}/molecule"
delegate_to: localhost
- name: "Ensure playbook directory exists on live environment"
ansible.builtin.file:
path: "/opt/ansible-distro-configure"
state: "directory"
mode: "0750"
- name: "Unarchive playbook on live environment"
ansible.builtin.unarchive:
src: "/tmp/ansible-distro-configure.tar.gz"
dest: "/opt/ansible-distro-configure/"
list_files: false
remote_src: false
- name: "Update configure playbook inventory"
ansible.builtin.copy:
dest: "/opt/ansible-distro-configure/inventory/hosts.yml"
mode: "0640"
content: |
{{ hostname }}:
vars:
ansible_user: "root"
ansible_connection: "chroot"
ansible_chroot_exe: "arch-chroot"
hosts:
{{ configure_chroot_path }}:
- name: "Download playbook dependencies on live environment"
ansible.builtin.command:
cmd: "ansible-galaxy install -r /opt/ansible-distro-configure/requirements.yml"
changed_when: true
- name: "Run configure playbook using chroot connection"
ansible.builtin.command:
cmd: |
ansible-playbook site.yml
--limit "{{ hostname }}"
--extra-vars '{"hostname":"{{ hostname }}"}'
--extra-vars "@/opt/ansible-distro-configure/host_vars/{{ hostname }}.yml"
--tags 'required_for_boot'
chdir: "/opt/ansible-distro-configure"
register: configure_playbook
changed_when: true
- name: "Playbook stdout"
ansible.builtin.debug:
msg: "{{ configure_playbook.stdout_lines }}"
|