|
| 1 | +- name: Slurp cinder.conf from controller |
| 2 | + become: true |
| 3 | + ansible.builtin.shell: | |
| 4 | + {{ shell_header }} |
| 5 | + CONTROLLER1_SCP="{{ controller1_ssh | regex_replace('^ssh', 'scp')}}" |
| 6 | + ${CONTROLLER1_SCP}:{{ cinder_tripleo_path }} {{ cinder_conf_path }} |
| 7 | + chmod a+r {{ cinder_conf_path }} |
| 8 | +
|
| 9 | +- name: Stat the retrieved cinder.conf file |
| 10 | + ansible.builtin.stat: |
| 11 | + path: "{{ cinder_conf_path }}" |
| 12 | + register: cinder_conf |
| 13 | + |
| 14 | +- name: Fail if cinder.conf is not present |
| 15 | + when: not cinder_conf.stat.exists |
| 16 | + ansible.builtin.fail: |
| 17 | + msg: "cinder.conf does not exist" |
| 18 | + |
| 19 | +- name: Check the cinder share config file for ontap-nfs |
| 20 | + when: cinder_volume_backend == 'ontap-nfs' |
| 21 | + block: |
| 22 | + - name: Slurp cinder share config file from controller |
| 23 | + become: true |
| 24 | + ansible.builtin.shell: | |
| 25 | + {{ shell_header }} |
| 26 | + CONTROLLER1_SCP="{{ controller1_ssh | regex_replace('^ssh', 'scp')}}" |
| 27 | + ${CONTROLLER1_SCP}:{{ cinder_tripleo_nfs_shares_config_path }} {{ cinder_nfs_shares_conf_path }} |
| 28 | + chmod a+r {{ cinder_nfs_shares_conf_path }} |
| 29 | +
|
| 30 | + - name: Stat the retrieved cinder share config file |
| 31 | + ansible.builtin.stat: |
| 32 | + path: "{{ cinder_nfs_shares_conf_path }}" |
| 33 | + register: cinder_nfs_shares_conf |
| 34 | + |
| 35 | + - name: Fail if cinder share config file is not present |
| 36 | + when: not cinder_nfs_shares_conf.stat.exists |
| 37 | + ansible.builtin.fail: |
| 38 | + msg: "{{ cinder_nfs_shares_conf_path }} does not exist" |
| 39 | + |
| 40 | +- name: Deploy Podified Cinder-Volume - Netapp |
| 41 | + vars: |
| 42 | + cinder_netapp_config: | |
| 43 | + {% set cinder_netapp_conf = {} %} |
| 44 | + {% for item in cinder_volume_netapp_vars %} |
| 45 | + {% set value = lookup('ansible.builtin.ini', item, file=cinder_conf_path, section=cinder_netapp_backend, allow_no_value=True) %} |
| 46 | + {% set _ = cinder_netapp_conf.__setitem__(item, value) %} |
| 47 | + {% endfor %} |
| 48 | + {{ cinder_netapp_conf }} |
| 49 | + cinder_netapp_share_config: |
| 50 | + nfs_server: "{{ (lookup('file', cinder_nfs_shares_conf_path, errors='warn')).split(':')[0] | default('') | trim }}" |
| 51 | + nfs_path: "{{ (lookup('file', cinder_nfs_shares_conf_path, errors='warn')).split(':')[1] | default('') | trim }}" |
| 52 | + cinder_configuration_template: |
| 53 | + ontap-nfs: 'cinder_volume_netapp_nfs.yaml.j2' |
| 54 | + ontap-iscsi: 'cinder_volume_netapp_iscsi.yaml.j2' |
| 55 | + block: |
| 56 | + - name: Fail if cinder_netapp_config params are not defined |
| 57 | + when: | |
| 58 | + cinder_netapp_config.netapp_login is not defined or |
| 59 | + cinder_netapp_config.netapp_password is not defined or |
| 60 | + cinder_netapp_config.netapp_vserver is not defined or |
| 61 | + cinder_netapp_config.netapp_server_hostname is not defined |
| 62 | + ansible.builtin.fail: |
| 63 | + msg: |
| 64 | + - 'Missing required Netapp input' |
| 65 | + |
| 66 | + - name: Fail if cinder_netapp_share_config params are not defined |
| 67 | + when: | |
| 68 | + cinder_volume_backend == 'ontap-nfs' and |
| 69 | + (not cinder_netapp_share_config.nfs_server or |
| 70 | + not cinder_netapp_share_config.nfs_path) |
| 71 | + ansible.builtin.fail: |
| 72 | + msg: |
| 73 | + - 'Missing required cinder share input' |
| 74 | + |
| 75 | + - name: Render Netapp OpenShift Secret template |
| 76 | + ansible.builtin.template: |
| 77 | + src: "{{ role_path }}/templates/cinder-volume-ontap-secrets.yaml.j2" |
| 78 | + dest: /tmp/cinder-volume-ontap-secrets.yaml |
| 79 | + mode: "0600" |
| 80 | + |
| 81 | + - name: Render cinder netapp OpenShift patch file template |
| 82 | + ansible.builtin.template: |
| 83 | + src: "{{ role_path }}/templates/{{ cinder_configuration_template[cinder_volume_backend] }}" |
| 84 | + dest: /tmp/cinder_volume_netapp_config.yaml |
| 85 | + mode: "0600" |
| 86 | + |
| 87 | + - name: Apply the rendered Netapp secret in the openstack namespace |
| 88 | + ansible.builtin.shell: | |
| 89 | + {{ shell_header }} |
| 90 | + {{ oc_header }} |
| 91 | + oc apply -f /tmp/cinder-volume-ontap-secrets.yaml |
| 92 | +
|
| 93 | + - name: Configure the appropriate netapp backend |
| 94 | + ansible.builtin.shell: | |
| 95 | + {{ shell_header }} |
| 96 | + {{ oc_header }} |
| 97 | + oc patch openstackcontrolplane openstack --type=merge --patch-file=/tmp/cinder_volume_netapp_config.yaml |
0 commit comments