Merge pull request #3174 from kubernetes-incubator/revert-3147-etcd-cleanup

Revert "gen_certs_script: refactor using stdin (Ansible 2.4+)"
This commit is contained in:
Aivars Sterns 2018-08-24 12:51:45 +03:00 committed by GitHub
commit dd55458315
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -94,9 +94,9 @@
- facts - facts
- name: Gen_certs | Gather etcd master certs - name: Gen_certs | Gather etcd master certs
command: "tar cfz - -C {{ etcd_cert_dir }} -T /dev/stdin" shell: "tar cfz - -C {{ etcd_cert_dir }} -T /dev/stdin <<< {{ my_master_certs|join(' ') }} {{ all_node_certs|join(' ') }} | base64 --wrap=0"
args: args:
input: "{{ my_master_certs|join(' ') }} {{ all_node_certs|join(' ') }}" executable: /bin/bash
register: etcd_master_cert_data register: etcd_master_cert_data
no_log: true no_log: true
check_mode: no check_mode: no
@ -106,9 +106,9 @@
notify: set etcd_secret_changed notify: set etcd_secret_changed
- name: Gen_certs | Gather etcd node certs - name: Gen_certs | Gather etcd node certs
command: "tar cfz - -C {{ etcd_cert_dir }} -T /dev/stdin" shell: "tar cfz - -C {{ etcd_cert_dir }} -T /dev/stdin <<< {{ my_node_certs|join(' ') }} | base64 --wrap=0"
args: args:
stdin: "{{ my_node_certs|join(' ') }}" executable: /bin/bash
register: etcd_node_cert_data register: etcd_node_cert_data
no_log: true no_log: true
check_mode: no check_mode: no
@ -118,10 +118,27 @@
sync_certs|default(false) and inventory_hostname not in groups['etcd'] sync_certs|default(false) and inventory_hostname not in groups['etcd']
notify: set etcd_secret_changed notify: set etcd_secret_changed
# NOTE(mattymo): Use temporary file to copy master certs because we have a ~200k
# char limit when using shell command
# FIXME(mattymo): Use tempfile module in ansible 2.3
- name: Gen_certs | Prepare tempfile for unpacking certs
command: mktemp /tmp/certsXXXXX.tar.gz
register: cert_tempfile
when: inventory_hostname in groups['etcd'] and sync_certs|default(false) and
inventory_hostname != groups['etcd'][0]
- name: Gen_certs | Write master certs to tempfile
copy:
content: "{{etcd_master_cert_data.stdout}}"
dest: "{{cert_tempfile.stdout}}"
owner: root
mode: "0600"
when: inventory_hostname in groups['etcd'] and sync_certs|default(false) and
inventory_hostname != groups['etcd'][0]
- name: Gen_certs | Unpack certs on masters - name: Gen_certs | Unpack certs on masters
command: "tar xz -C {{ etcd_cert_dir }}" shell: "base64 -d < {{ cert_tempfile.stdout }} | tar xz -C {{ etcd_cert_dir }}"
args:
stdin: "{{ etcd_master_cert_data.stdout }}"
no_log: true no_log: true
changed_when: false changed_when: false
check_mode: no check_mode: no
@ -129,11 +146,17 @@
inventory_hostname != groups['etcd'][0] inventory_hostname != groups['etcd'][0]
notify: set secret_changed notify: set secret_changed
- name: Gen_certs | Cleanup tempfile
file:
path: "{{cert_tempfile.stdout}}"
state: absent
when: inventory_hostname in groups['etcd'] and sync_certs|default(false) and
inventory_hostname != groups['etcd'][0]
- name: Gen_certs | Copy certs on nodes - name: Gen_certs | Copy certs on nodes
command: "tar xz -C {{ etcd_cert_dir }}" shell: "base64 -d <<< '{{etcd_node_cert_data.stdout|quote}}' | tar xz -C {{ etcd_cert_dir }}"
args: args:
stdin: "{{ etcd_node_cert_data.stdout }}" executable: /bin/bash
no_log: true
changed_when: false changed_when: false
when: sync_certs|default(false) and when: sync_certs|default(false) and
inventory_hostname not in groups['etcd'] inventory_hostname not in groups['etcd']