risotto/ansible/machines.yml

72 lines
2 KiB
YAML
Raw Normal View History

2023-01-23 20:23:32 +01:00
- name: "Rebuild images"
ansible.builtin.shell: "/usr/local/sbin/update_images just_need_images"
register: ret
failed_when: ret.rc != 0
2023-02-27 14:03:56 +01:00
- name: "Stop machine TLS"
machinectl:
state: stopped
machines: "{{ build_host.tls_machine }}"
tls_machine: "{{ build_host.tls_machine }}"
when: build_host.tls_machine in build_host.machines_changed
- name: "Remove TLS files directory"
file:
path: "/var/lib/risotto/configurations/{{ build_host.tls_machine }}"
state: absent
when: build_host.tls_machine in build_host.machines_changed
- name: "Copy TLS configuration"
unarchive:
src: /tmp/new_configurations/machines.tar
dest: "/var/lib/risotto/configurations/"
include: "{{ build_host.tls_machine }}"
owner: root
group: root
when: build_host.tls_machine in build_host.machines_changed
- name: "Start machine TLS"
machinectl:
state: started
machines: "{{ build_host.tls_machine }}"
tls_machine: "{{ build_host.tls_machine }}"
when: build_host.tls_machine in build_host.machines_changed
2023-01-23 20:23:32 +01:00
- name: "Stop machines with new configuration {{ build_host.machines_changed }}"
2022-10-01 22:33:11 +02:00
machinectl:
state: stopped
2023-01-23 20:23:32 +01:00
machines: "{{ build_host.machines_changed }}"
2023-02-27 14:03:56 +01:00
tls_machine: "{{ build_host.tls_machine }}"
2022-10-01 22:33:11 +02:00
- name: "Remove files directory"
file:
path: "/var/lib/risotto/configurations/{{ item }}"
state: absent
2023-01-23 20:23:32 +01:00
loop: "{{ build_host.machines_changed }}"
2022-10-01 22:33:11 +02:00
- name: "Copy configuration"
unarchive:
2023-01-23 20:23:32 +01:00
src: /tmp/new_configurations/machines.tar
dest: /var/lib/risotto/configurations/
2022-12-21 16:35:58 +01:00
owner: root
group: root
2023-01-23 20:23:32 +01:00
when: build_host.machines_changed
2022-10-01 22:33:11 +02:00
- name: "Enable machines"
machinectl:
state: enabled
machines: "{{ vars | machineslist(only_name=True) }}"
2023-02-27 14:03:56 +01:00
tls_machine: "{{ build_host.tls_machine }}"
2022-10-01 22:33:11 +02:00
- name: "Start machines"
machinectl:
state: started
machines: "{{ vars | machineslist(only_name=True) }}"
2023-02-27 14:03:56 +01:00
tls_machine: "{{ build_host.tls_machine }}"
2022-10-01 22:33:11 +02:00
- name: "Remove compressed files directory"
local_action:
module: file
path: /tmp/new_configurations
state: absent