Replace w/ loop key; Change scope of polling task
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
d4f366232e
commit
ae358ce60e
48
playbook.yml
48
playbook.yml
@ -37,11 +37,11 @@
|
|||||||
guestinfo.prefixlength: "{{ item.ip | ansible.utils.ipaddr('prefix') }}"
|
guestinfo.prefixlength: "{{ item.ip | ansible.utils.ipaddr('prefix') }}"
|
||||||
guestinfo.dnsserver: "{{ network.dnsserver }}"
|
guestinfo.dnsserver: "{{ network.dnsserver }}"
|
||||||
guestinfo.gateway: "{{ network.gateway }}"
|
guestinfo.gateway: "{{ network.gateway }}"
|
||||||
delegate_to: localhost
|
|
||||||
with_items: "{{ servers }}"
|
|
||||||
register: job_init
|
register: job_init
|
||||||
async: 300
|
async: 300
|
||||||
poll: 0
|
poll: 0
|
||||||
|
delegate_to: localhost
|
||||||
|
loop: "{{ servers }}"
|
||||||
|
|
||||||
- name: Pause to allow initial calls to complete
|
- name: Pause to allow initial calls to complete
|
||||||
ansible.builtin.pause:
|
ansible.builtin.pause:
|
||||||
@ -50,38 +50,38 @@
|
|||||||
- name: Poll for completion
|
- name: Poll for completion
|
||||||
ansible.builtin.async_status:
|
ansible.builtin.async_status:
|
||||||
jid: "{{ item.ansible_job_id }}"
|
jid: "{{ item.ansible_job_id }}"
|
||||||
with_items: "{{ job_init.results }}"
|
|
||||||
register: job_poll
|
register: job_poll
|
||||||
retries: 5
|
retries: 5
|
||||||
delay: 100
|
delay: 100
|
||||||
until: job_poll.finished
|
until: job_poll.finished
|
||||||
|
loop: "{{ job_init.results }}"
|
||||||
|
|
||||||
- name: Parse results into dictionary
|
- name: Parse results into dictionary
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
nodes: "{{ nodes | default([]) + [ {'name': item.instance.hw_name, 'ip': item.item.item.ip | ansible.utils.ipaddr('address')} ] }}"
|
nodes: "{{ nodes | default([]) + [ {'name': item.instance.hw_name, 'ip': item.item.item.ip | ansible.utils.ipaddr('address')} ] }}"
|
||||||
with_items: "{{ job_poll | json_query('results[*]') }}"
|
loop: "{{ job_poll | json_query('results[*]') }}"
|
||||||
# Purely to avoid large amount of spam; no sensitive data here.
|
loop_control:
|
||||||
no_log: true
|
label: "{{ { 'name': item.item.name, 'ip': item.item.ip } }}"
|
||||||
|
|
||||||
- name: Register new VM's in inventory
|
- name: Register new VM's in inventory
|
||||||
ansible.builtin.add_host:
|
ansible.builtin.add_host:
|
||||||
name: "{{ item.name }}"
|
name: "{{ item.name }}"
|
||||||
ansible_host: "{{ item.ip }}"
|
ansible_host: "{{ item.ip }}"
|
||||||
groups: k3s_ha
|
groups: k3s_ha
|
||||||
with_items: "{{ nodes }}"
|
loop: "{{ nodes }}"
|
||||||
|
|
||||||
- name: Wait for systems to become reachable over SSH
|
- name: Wait for systems to become reachable over SSH
|
||||||
ansible.builtin.wait_for:
|
ansible.builtin.wait_for:
|
||||||
host: "{{ item.ip }}"
|
host: "{{ item.ip }}"
|
||||||
port: 22
|
port: 22
|
||||||
timeout: 300
|
timeout: 300
|
||||||
with_items: "{{ nodes }}"
|
loop: "{{ nodes }}"
|
||||||
|
|
||||||
- name: Scan public keys
|
- name: Scan public keys
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
cmd: "ssh-keyscan -t rsa {{ item.ip }}"
|
cmd: "ssh-keyscan -t rsa {{ item.ip }}"
|
||||||
register: publickeys
|
register: publickeys
|
||||||
with_items: "{{ nodes }}"
|
loop: "{{ nodes }}"
|
||||||
|
|
||||||
- name: Store public keys
|
- name: Store public keys
|
||||||
ansible.builtin.known_hosts:
|
ansible.builtin.known_hosts:
|
||||||
@ -89,9 +89,9 @@
|
|||||||
key: "{{ item.item.name | lower }},{{ item.stdout }}"
|
key: "{{ item.item.name | lower }},{{ item.stdout }}"
|
||||||
state: present
|
state: present
|
||||||
path: ~/.ssh/known_hosts
|
path: ~/.ssh/known_hosts
|
||||||
with_items: "{{ publickeys.results }}"
|
loop: "{{ publickeys.results }}"
|
||||||
# Purely to avoid large amount of spam; no sensitive data here.
|
loop_control:
|
||||||
no_log: true
|
label: "{{ { 'name': item.item.name, 'ip': item.item.ip } }}"
|
||||||
|
|
||||||
- name: Provision Kubernetes
|
- name: Provision Kubernetes
|
||||||
hosts: k3s_ha
|
hosts: k3s_ha
|
||||||
@ -137,19 +137,19 @@
|
|||||||
src: kube-vip.j2
|
src: kube-vip.j2
|
||||||
dest: /var/lib/rancher/k3s/server/manifests/kube-vip.yml
|
dest: /var/lib/rancher/k3s/server/manifests/kube-vip.yml
|
||||||
|
|
||||||
- name: Initial node -- Wait for available API
|
delegate_to: "{{ ansible_play_hosts[0] }}"
|
||||||
ansible.utils.cli_parse:
|
run_once: true
|
||||||
command: "curl -k https://{{ cluster.virtualip | ansible.utils.ipaddr('address') }}:6443/livez?verbose"
|
|
||||||
parser:
|
|
||||||
name: ansible.utils.json
|
|
||||||
set_fact: api_readycheck
|
|
||||||
ignore_errors: yes
|
|
||||||
until: api_readycheck.apiVersion is defined
|
|
||||||
retries: 3
|
|
||||||
delay: 30
|
|
||||||
|
|
||||||
delegate_to: "{{ ansible_play_hosts[0] }}"
|
- name: All nodes -- Ensure API availability
|
||||||
run_once: true
|
ansible.utils.cli_parse:
|
||||||
|
command: "curl -k https://{{ cluster.virtualip | ansible.utils.ipaddr('address') }}:6443/livez?verbose"
|
||||||
|
parser:
|
||||||
|
name: ansible.utils.json
|
||||||
|
set_fact: api_readycheck
|
||||||
|
ignore_errors: yes
|
||||||
|
until: api_readycheck.apiVersion is defined
|
||||||
|
retries: 3
|
||||||
|
delay: 30
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user