|
31 | 31 | # For nmstate, always enable NetworkManager DNS management |
32 | 32 | edpm_bootstrap_network_resolvconf_update: true |
33 | 33 |
|
| 34 | +- name: Check nmstate return code for conditional logic |
| 35 | + become: true |
| 36 | + block: |
| 37 | + - name: Check if nmstate return code file exists |
| 38 | + ansible.builtin.stat: |
| 39 | + path: /var/lib/edpm-config/nmstate.returncode |
| 40 | + register: nmstate_returncode_stat |
| 41 | + |
| 42 | + - name: Read nmstate return code file if it exists |
| 43 | + ansible.builtin.slurp: |
| 44 | + path: /var/lib/edpm-config/nmstate.returncode |
| 45 | + register: nmstate_returncode_slurp |
| 46 | + when: nmstate_returncode_stat.stat.exists |
| 47 | + |
34 | 48 | - name: Configure network with network role from system roles [nmstate] |
35 | 49 | become: true |
| 50 | + when: |
| 51 | + - (edpm_network_config_update) or |
| 52 | + (nmstate_returncode_stat.stat.exists and |
| 53 | + ((nmstate_returncode_slurp.content | b64decode | int) != 0)) or |
| 54 | + (not nmstate_returncode_stat.stat.exists) |
36 | 55 | block: |
37 | 56 | - name: Render network_state variable |
38 | 57 | ansible.builtin.set_fact: |
|
42 | 61 | ansible.builtin.include_role: |
43 | 62 | name: "{{ lookup('ansible.builtin.env', 'EDPM_SYSTEMROLES', default='fedora.linux_system_roles') + '.network' }}" |
44 | 63 | register: nmstate_result |
| 64 | + |
| 65 | + - name: Ensure /var/lib/edpm-config exists |
| 66 | + ansible.builtin.file: |
| 67 | + path: /var/lib/edpm-config |
| 68 | + state: directory |
| 69 | + mode: "0755" |
| 70 | + |
| 71 | + - name: Write rc of nmstate run |
| 72 | + ansible.builtin.copy: |
| 73 | + content: "{{ nmstate_result.rc if nmstate_result.rc is defined else (1 if (nmstate_result.failed|default(false)) else 0) }}" |
| 74 | + dest: /var/lib/edpm-config/nmstate.returncode |
| 75 | + mode: "0644" |
| 76 | + when: |
| 77 | + - nmstate_result is defined |
0 commit comments