FIX: Unneded (extra) cycles in some tasks

This commit is contained in:
Anton Nerozya 2017-06-24 13:26:47 +02:00
parent eb15a2b550
commit a2e1ad9f7a
6 changed files with 16 additions and 0 deletions

View file

@ -8,6 +8,7 @@
"member-" + item + ".pem" "member-" + item + ".pem"
] }} ] }}
with_items: "{{ groups.etcd }}" with_items: "{{ groups.etcd }}"
run_once: true
- include: ../../vault/tasks/shared/sync_file.yml - include: ../../vault/tasks/shared/sync_file.yml
vars: vars:
@ -16,6 +17,7 @@
sync_file_hosts: "{{ groups.etcd }}" sync_file_hosts: "{{ groups.etcd }}"
sync_file_is_cert: true sync_file_is_cert: true
with_items: "{{ etcd_master_cert_list|d([]) }}" with_items: "{{ etcd_master_cert_list|d([]) }}"
run_once: true
- name: sync_etcd_certs | Set facts for etcd sync_file results - name: sync_etcd_certs | Set facts for etcd sync_file results
set_fact: set_fact:
@ -32,6 +34,7 @@
sync_file: ca.pem sync_file: ca.pem
sync_file_dir: "{{ etcd_cert_dir }}" sync_file_dir: "{{ etcd_cert_dir }}"
sync_file_hosts: "{{ groups.etcd }}" sync_file_hosts: "{{ groups.etcd }}"
run_once: true
- name: sync_etcd_certs | Unset sync_file_results after ca.pem sync - name: sync_etcd_certs | Unset sync_file_results after ca.pem sync
set_fact: set_fact:

View file

@ -4,6 +4,7 @@
set_fact: set_fact:
etcd_node_cert_list: "{{ etcd_node_cert_list|default([]) + ['node-' + item + '.pem'] }}" etcd_node_cert_list: "{{ etcd_node_cert_list|default([]) + ['node-' + item + '.pem'] }}"
with_items: "{{ etcd_node_cert_hosts }}" with_items: "{{ etcd_node_cert_hosts }}"
run_once: true
- include: ../../vault/tasks/shared/sync_file.yml - include: ../../vault/tasks/shared/sync_file.yml
vars: vars:
@ -12,6 +13,7 @@
sync_file_hosts: "{{ etcd_node_cert_hosts }}" sync_file_hosts: "{{ etcd_node_cert_hosts }}"
sync_file_is_cert: true sync_file_is_cert: true
with_items: "{{ etcd_node_cert_list|d([]) }}" with_items: "{{ etcd_node_cert_list|d([]) }}"
run_once: true
- name: sync_etcd_node_certs | Set facts for etcd sync_file results - name: sync_etcd_node_certs | Set facts for etcd sync_file results
set_fact: set_fact:
@ -28,6 +30,7 @@
sync_file: ca.pem sync_file: ca.pem
sync_file_dir: "{{ etcd_cert_dir }}" sync_file_dir: "{{ etcd_cert_dir }}"
sync_file_hosts: "{{ etcd_node_cert_hosts }}" sync_file_hosts: "{{ etcd_node_cert_hosts }}"
run_once: true
- name: sync_etcd_node_certs | Unset sync_file_results after ca.pem - name: sync_etcd_node_certs | Unset sync_file_results after ca.pem
set_fact: set_fact:

View file

@ -6,6 +6,7 @@
delegate_to: "{{item}}" delegate_to: "{{item}}"
with_items: "{{groups['kube-master']}}" with_items: "{{groups['kube-master']}}"
when: needs_etcd_migration|bool when: needs_etcd_migration|bool
run_once: true
- name: "Post-upgrade | Pause for kubelet stop" - name: "Post-upgrade | Pause for kubelet stop"
pause: pause:
@ -19,6 +20,7 @@
delegate_to: "{{item}}" delegate_to: "{{item}}"
with_items: "{{groups['kube-master']}}" with_items: "{{groups['kube-master']}}"
when: needs_etcd_migration|bool when: needs_etcd_migration|bool
run_once: true
- name: "Post-upgrade | etcd3 upgrade | purge etcd2 k8s data" - name: "Post-upgrade | etcd3 upgrade | purge etcd2 k8s data"
command: "{{ bin_dir }}/etcdctl --endpoints={{ etcd_access_addresses }} rm -r /registry" command: "{{ bin_dir }}/etcdctl --endpoints={{ etcd_access_addresses }} rm -r /registry"

View file

@ -79,6 +79,7 @@
- ["kube-apiserver", "kube-controller-manager", "kube-scheduler"] - ["kube-apiserver", "kube-controller-manager", "kube-scheduler"]
register: kube_apiserver_manifest_replaced register: kube_apiserver_manifest_replaced
when: (secret_changed|default(false) or etcd_secret_changed|default(false) or needs_etcd_migration|bool) and kube_apiserver_manifest.stat.exists when: (secret_changed|default(false) or etcd_secret_changed|default(false) or needs_etcd_migration|bool) and kube_apiserver_manifest.stat.exists
run_once: true
- name: "Pre-upgrade | etcd3 upgrade | stop etcd" - name: "Pre-upgrade | etcd3 upgrade | stop etcd"
service: service:
@ -87,6 +88,7 @@
delegate_to: "{{item}}" delegate_to: "{{item}}"
with_items: "{{groups['etcd']}}" with_items: "{{groups['etcd']}}"
when: needs_etcd_migration|bool when: needs_etcd_migration|bool
run_once: true
- name: "Pre-upgrade | etcd3 upgrade | migrate data" - name: "Pre-upgrade | etcd3 upgrade | migrate data"
command: "{{ bin_dir }}/etcdctl migrate --data-dir=\"{{ etcd_data_dir }}\" --wal-dir=\"{{ etcd_data_dir }}/member/wal\"" command: "{{ bin_dir }}/etcdctl migrate --data-dir=\"{{ etcd_data_dir }}\" --wal-dir=\"{{ etcd_data_dir }}/member/wal\""
@ -96,6 +98,7 @@
with_items: "{{groups['etcd']}}" with_items: "{{groups['etcd']}}"
register: etcd_migrated register: etcd_migrated
when: needs_etcd_migration|bool when: needs_etcd_migration|bool
run_once: true
- name: "Pre-upgrade | etcd3 upgrade | start etcd" - name: "Pre-upgrade | etcd3 upgrade | start etcd"
service: service:
@ -104,3 +107,4 @@
delegate_to: "{{item}}" delegate_to: "{{item}}"
with_items: "{{groups['etcd']}}" with_items: "{{groups['etcd']}}"
when: needs_etcd_migration|bool when: needs_etcd_migration|bool
run_once: true

View file

@ -29,3 +29,4 @@
set_fact: set_fact:
vault_cluster_is_initialized: "{{ vault_is_initialized or hostvars[item]['vault_is_initialized'] }}" vault_cluster_is_initialized: "{{ vault_is_initialized or hostvars[item]['vault_is_initialized'] }}"
with_items: "{{ groups.vault }}" with_items: "{{ groups.vault }}"
run_once: true

View file

@ -15,3 +15,6 @@
vault_leader_url: "{{ vault_config.listener.tcp.tls_disable|d()|ternary('http', 'https') }}://{{ item }}:{{ vault_port }}" vault_leader_url: "{{ vault_config.listener.tcp.tls_disable|d()|ternary('http', 'https') }}://{{ item }}:{{ vault_port }}"
with_items: "{{ groups.vault }}" with_items: "{{ groups.vault }}"
when: "hostvars[item]['vault_leader_check'].get('status') == 200" when: "hostvars[item]['vault_leader_check'].get('status') == 200"
run_once: true
- debug: var=vault_leader_url verbosity=2