- name: Copy the build ssh key to authorized_keys on all hosts for root hosts: all roles: - copy-build-sshkey - hosts: all gather_facts: false tasks: - name: Set IP addresses for the nodes missing private IPs ansible.builtin.set_fact: nodepool_ip: "{{ nodepool.public_ipv4 }}" when: not (nodepool.private_ipv4 | ipv4) - name: Set IP addresses for the nodes without private IPs (a fallback) ansible.builtin.set_fact: nodepool_ip: "{{ nodepool.private_ipv4 | default(nodepool.public_ipv4) }}" when: nodepool_ip is not defined - hosts: all tasks: - name: Create nodepool directory become: true ansible.builtin.file: path: /etc/nodepool state: directory mode: '0777' - name: Create nodepool sub_nodes file ansible.builtin.copy: dest: /etc/nodepool/sub_nodes content: "" - name: Create nodepool sub_nodes_private file ansible.builtin.copy: dest: /etc/nodepool/sub_nodes_private content: "" - name: Populate nodepool sub_nodes file ansible.builtin.lineinfile: path: /etc/nodepool/sub_nodes line: "{{ hostvars[item]['nodepool']['public_ipv4'] }}" loop: "{{ groups['subnodes'] }}" when: groups['subnodes'] is defined - name: Populate nodepool sub_nodes_private file ansible.builtin.lineinfile: path: /etc/nodepool/sub_nodes_private line: "{{ hostvars[item]['nodepool_ip'] }}" insertafter: EOF loop: "{{ groups['subnodes'] }}" when: groups['subnodes'] is defined - name: Create nodepool primary file ansible.builtin.copy: dest: /etc/nodepool/primary_node_private content: "{{ hostvars['primary']['nodepool_ip'] }}" when: hostvars['primary'] is defined - name: Create nodepool node_private for this node ansible.builtin.copy: dest: /etc/nodepool/node_private content: "{{ nodepool_ip }}"