risotto/ansible/machines.yml

44 lines
1.1 KiB
YAML
Raw Normal View History

2023-01-23 20:23:32 +01:00
#- name: Print return information from the previous task
# ansible.builtin.debug:
# var: build_host.machines_changed
- name: "Rebuild images"
ansible.builtin.shell: "/usr/local/sbin/update_images just_need_images"
register: ret
failed_when: ret.rc != 0
- 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 }}"
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) }}"
2022-10-01 22:33:11 +02:00
- name: "Start machines"
machinectl:
state: started
machines: "{{ vars | machineslist(only_name=True) }}"
- name: "Remove compressed files directory"
local_action:
module: file
path: /tmp/new_configurations
state: absent