Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add gather facts on all hosts in inventory #5936

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@
- { role: kubespray-defaults }
- { role: bootstrap-os, tags: bootstrap-os}

- name: Gather facts
hosts: localhost
gather_facts: false
become: no
tasks:
- name: Gather facts from ALL hosts (regardless of limit or tags)
setup:
delegate_to: "{{ item }}"
delegate_facts: True
when: hostvars[item]['ansible_default_ipv4'] is not defined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be ansible_default_ipv4.address?

Or using something like this:
when: (hostvars[item] is defined) and (hostvars[item]['ansible_default_ipv4'] is defined) and (hostvars[item]['ansible_default_ipv4']['address'] is defined)

with_items: "{{ groups['all'] }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to ignore errors, else we can't run the playbook when a host is down


- hosts: k8s-cluster:etcd
any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
roles:
Expand Down
12 changes: 12 additions & 0 deletions scale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@
- { role: kubespray-defaults }
- { role: bootstrap-os, tags: bootstrap-os}

- name: Gather facts
hosts: localhost
gather_facts: false
become: no
tasks:
- name: Gather facts from ALL hosts (regardless of limit or tags)
setup:
delegate_to: "{{ item }}"
delegate_facts: True
when: hostvars[item]['ansible_default_ipv4'] is not defined
with_items: "{{ groups['all'] }}"

- name: Generate the etcd certificates beforehand
hosts: etcd
any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
Expand Down
12 changes: 12 additions & 0 deletions upgrade-cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@
- { role: kubespray-defaults }
- { role: bootstrap-os, tags: bootstrap-os}

- name: Gather facts
hosts: localhost
gather_facts: false
become: no
tasks:
- name: Gather facts from ALL hosts (regardless of limit or tags)
setup:
delegate_to: "{{ item }}"
delegate_facts: True
when: hostvars[item]['ansible_default_ipv4'] is not defined
with_items: "{{ groups['all'] }}"

- name: Download images to ansible host cache via first kube-master node
hosts: kube-master[0]
any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
Expand Down