You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.4 KiB

9 years ago
8 years ago
9 years ago
8 years ago
9 years ago
8 years ago
9 years ago
8 years ago
9 years ago
8 years ago
9 years ago
8 years ago
  1. ---
  2. - name: Secrets | certs | make sure the certificate directory exits
  3. file:
  4. path={{ kube_cert_dir }}
  5. state=directory
  6. mode=o-rwx
  7. group={{ kube_cert_group }}
  8. - name: Secrets | tokens | make sure the tokens directory exits
  9. file:
  10. path={{ kube_token_dir }}
  11. state=directory
  12. mode=o-rwx
  13. group={{ kube_cert_group }}
  14. - include: gen_certs.yml
  15. when: inventory_hostname == groups['kube-master'][0]
  16. - include: gen_calico_tokens.yml
  17. # Sync certs between nodes
  18. - name: Secrets | create user
  19. user:
  20. name: '{{ansible_user_id}}'
  21. generate_ssh_key: yes
  22. delegate_to: "{{ groups['kube-master'][0] }}"
  23. run_once: yes
  24. - name: Secrets | 'get ssh keypair'
  25. slurp: path=~/.ssh/id_rsa.pub
  26. register: public_key
  27. delegate_to: "{{ groups['kube-master'][0] }}"
  28. - name: Secrets | 'setup keypair on nodes'
  29. authorized_key:
  30. user: '{{ansible_user_id}}'
  31. key: "{{public_key.content|b64decode }}"
  32. - name: Secrets | synchronize certificates for nodes
  33. synchronize:
  34. src: "{{ item }}"
  35. dest: "{{ kube_cert_dir }}"
  36. recursive: yes
  37. delete: yes
  38. rsync_opts: [ '--one-file-system']
  39. set_remote_user: false
  40. with_items:
  41. - "{{ kube_cert_dir}}/ca.pem"
  42. - "{{ kube_cert_dir}}/node.pem"
  43. - "{{ kube_cert_dir}}/node-key.pem"
  44. delegate_to: "{{ groups['kube-master'][0] }}"
  45. when: inventory_hostname not in "{{ groups['kube-master'] }}"