main.yml
| 1 |
- name: Instance or reconfigure
|
|---|---|
| 2 |
stat:
|
| 3 |
path: "/etc/eole/.instance" |
| 4 |
register: instanciated |
| 5 |
changed_when: true |
| 6 |
notify:
|
| 7 |
- Test if already configured
|
| 8 |
- Reconfigure
|
| 9 |
- Install python-pexpect
|
| 10 |
- Install python3-pexpect
|
| 11 |
- Instance
|
| 12 |
|
| 13 |
- name: Test if already instanciated
|
| 14 |
stat:
|
| 15 |
path: "/etc/eole/.instance" |
| 16 |
register: instanciated |
| 17 |
|
| 18 |
- name: Test if already configured
|
| 19 |
stat:
|
| 20 |
path: "/etc/eole/config.eol" |
| 21 |
register: configured |
| 22 |
|
| 23 |
- name: Reconfigure
|
| 24 |
shell:
|
| 25 |
cmd: /usr/bin/reconfigure |
| 26 |
when: instanciated.stat.exists and configured.stat.exists |
| 27 |
|
| 28 |
- name: Install python-pexpect
|
| 29 |
apt:
|
| 30 |
name: python-pexpect |
| 31 |
state: present |
| 32 |
when: ansible_python.version.major|int == 2 and not instanciated.stat.exists |
| 33 |
notify: Uninstall python-pexpect |
| 34 |
|
| 35 |
- name: Install python3-pexpect
|
| 36 |
apt:
|
| 37 |
name: python3-pexpect |
| 38 |
state: present |
| 39 |
when: ansible_python.version.major|int == 3 and not instanciated.stat.exists |
| 40 |
notify: Uninstall python3-pexpect |
| 41 |
|
| 42 |
- name: Instance
|
| 43 |
cadoles.eole.instance:
|
| 44 |
module: "{{ module_type }}" |
| 45 |
variables: "{{ module_instance_variables }}" |
| 46 |
when: not instanciated.stat.exists |
| 47 |
notify:
|
| 48 |
- Is reboot needed
|
| 49 |
|
| 50 |
- name: Uninstall python3-pexpect
|
| 51 |
apt:
|
| 52 |
name: python3-pexpect |
| 53 |
state: absent |
| 54 |
|
| 55 |
- name: Uninstall python-pexpect
|
| 56 |
apt:
|
| 57 |
name: python-pexpect |
| 58 |
state: absent |
| 59 |
|
| 60 |
- name: Refresh package lists
|
| 61 |
shell:
|
| 62 |
cmd: Query-Auto |
| 63 |
|
| 64 |
- name: Is reboot needed
|
| 65 |
shell:
|
| 66 |
cmd: "TERM=vt100 /usr/share/eole/diagnose/08-upgrade | awk '/Reboot/ {print $5}'" |
| 67 |
register: reboot_needed |
| 68 |
notify:
|
| 69 |
- Reboot
|
| 70 |
|
| 71 |
- name: Reboot
|
| 72 |
reboot:
|
| 73 |
reboot_timeout: 3600 |
| 74 |
search_paths:
|
| 75 |
- '/lib/molly-guard'
|
| 76 |
when: reboot_needed.stdout == "Oui" |
| 77 |
notify:
|
| 78 |
- Wait for host
|
| 79 |
|
| 80 |
- name: Wait for host
|
| 81 |
wait_for_connection:
|
| 82 |
delay: 10 |
| 83 |
sleep: 2 |
| 84 |
timeout: 800 |