risotto/ansible/machines.yml

70 lines
2.3 KiB
YAML
Raw Normal View History

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