|
14 | 14 | changed_when: not ansible_check_mode |
15 | 15 |
|
16 | 16 | - name: Create a corosync.conf file content |
17 | | - include_tasks: pcs-cluster-setup-{{ __ha_cluster_pcs_provider }}.yml |
| 17 | + command: |
| 18 | + cmd: > |
| 19 | + pcs cluster setup |
| 20 | + --corosync_conf {{ __ha_cluster_tempfile_corosync_conf.path | quote }} |
| 21 | + --overwrite |
| 22 | + {% if "cluster.config.uuid" in __ha_cluster_pcs_capabilities %} |
| 23 | + --no-cluster-uuid |
| 24 | + {% endif %} |
| 25 | + -- |
| 26 | + {{ ha_cluster_cluster_name | quote }} |
| 27 | + {% for node in ansible_play_hosts %} |
| 28 | + {{ hostvars[node].__ha_cluster_node_name | quote }} |
| 29 | + {% |
| 30 | + for addr in |
| 31 | + hostvars[node].__ha_cluster_local_node.corosync_addresses | d([]) |
| 32 | + %} |
| 33 | + addr={{ addr | quote }} |
| 34 | + {% endfor %} |
| 35 | + {% endfor %} |
| 36 | +
|
| 37 | + {% if ha_cluster_transport | d({}) %} |
| 38 | + transport {{ ha_cluster_transport.type | d('knet') | quote }} |
| 39 | + {% for option in ha_cluster_transport.options | d([]) %} |
| 40 | + {{ option.name | quote }}={{ option.value | quote }} |
| 41 | + {% endfor %} |
| 42 | + {% for link in ha_cluster_transport.links | d([]) %} |
| 43 | + link |
| 44 | + {% for option in link %} |
| 45 | + {{ option.name | quote }}={{ option.value | quote }} |
| 46 | + {% endfor %} |
| 47 | + {% endfor %} |
| 48 | + {% if ha_cluster_transport.compression | d([]) %} |
| 49 | + compression |
| 50 | + {% for option in ha_cluster_transport.compression %} |
| 51 | + {{ option.name | quote }}={{ option.value | quote }} |
| 52 | + {% endfor %} |
| 53 | + {% endif %} |
| 54 | + {% if ha_cluster_transport.crypto | d([]) %} |
| 55 | + crypto |
| 56 | + {% for option in ha_cluster_transport.crypto %} |
| 57 | + {{ option.name | quote }}={{ option.value | quote }} |
| 58 | + {% endfor %} |
| 59 | + {% endif %} |
| 60 | + {% endif %} |
| 61 | +
|
| 62 | + {% if ha_cluster_totem.options | d([]) %} |
| 63 | + totem |
| 64 | + {% for option in ha_cluster_totem.options %} |
| 65 | + {{ option.name | quote }}={{ option.value | quote }} |
| 66 | + {% endfor %} |
| 67 | + {% endif %} |
| 68 | +
|
| 69 | + {% |
| 70 | + if __ha_cluster_sbd_needs_atb | d(false) |
| 71 | + or ha_cluster_quorum.options | d([]) |
| 72 | + %} |
| 73 | + quorum |
| 74 | + {% for option in ha_cluster_quorum.options | d([]) %} |
| 75 | + {% if |
| 76 | + not __ha_cluster_sbd_needs_atb | d(false) |
| 77 | + or option.name != 'auto_tie_breaker' |
| 78 | + %} |
| 79 | + {{ option.name | quote }}={{ option.value | quote }} |
| 80 | + {% endif %} |
| 81 | + {% endfor %} |
| 82 | + {% if __ha_cluster_sbd_needs_atb | d(false) %} |
| 83 | + auto_tie_breaker=1 |
| 84 | + {% endif %} |
| 85 | + {% endif %} |
| 86 | + run_once: true # noqa: run_once[task] |
| 87 | + # We always need to create corosync.conf file to see whether it's the same as |
| 88 | + # what is already present on the cluster nodes. However, we don't want to |
| 89 | + # report it as a change since the only thing which matters is copying the |
| 90 | + # resulting corosync.conf to cluster nodes. |
| 91 | + check_mode: false |
| 92 | + changed_when: not ansible_check_mode |
| 93 | + |
| 94 | +- name: Add qdevice configuration to corosync.conf |
| 95 | + command: |
| 96 | + cmd: > |
| 97 | + pcs quorum device add |
| 98 | + --corosync_conf {{ __ha_cluster_tempfile_corosync_conf.path | quote }} |
| 99 | + -- |
| 100 | + {% for option in ha_cluster_quorum.device.generic_options | d([]) %} |
| 101 | + {{ option.name | quote }}={{ option.value | quote }} |
| 102 | + {% endfor %} |
| 103 | + model |
| 104 | + {{ ha_cluster_quorum.device.model | d() | quote }} |
| 105 | + {% for option in ha_cluster_quorum.device.model_options | d([]) %} |
| 106 | + {% if option.name != 'pcs-address' %} |
| 107 | + {{ option.name | quote }}={{ option.value | quote }} |
| 108 | + {% endif %} |
| 109 | + {% endfor %} |
| 110 | + {% if ha_cluster_quorum.device.heuristics_options | d([]) %} |
| 111 | + heuristics |
| 112 | + {% for option in ha_cluster_quorum.device.heuristics_options %} |
| 113 | + {{ option.name | quote }}={{ option.value | quote }} |
| 114 | + {% endfor %} |
| 115 | + {% endif %} |
| 116 | + run_once: true # noqa: run_once[task] |
| 117 | + when: |
| 118 | + - __ha_cluster_qdevice_in_use |
| 119 | + # We always need to create corosync.conf file to see whether it's the same as |
| 120 | + # what is already present on the cluster nodes. However, we don't want to |
| 121 | + # report it as a change since the only thing which matters is copying the |
| 122 | + # resulting corosync.conf to cluster nodes. |
| 123 | + check_mode: false |
| 124 | + changed_when: not ansible_check_mode |
18 | 125 |
|
19 | 126 | - name: Fetch created corosync.conf file |
20 | 127 | slurp: |
|
0 commit comments