certificates.yml 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. ---
  2. - name: Create tmp certificates directory
  3. file:
  4. path: ./tmp/{{ hostvars['ada'].inventory_hostname }}
  5. state: directory
  6. delegate_to: localhost
  7. - name: Create certificates directory
  8. file:
  9. path: /etc/nginx/certs
  10. state: directory
  11. - name: Copy crt from CA
  12. ansible.builtin.fetch:
  13. src: /etc/nginx/certs/{{ hostvars['ada'].inventory_hostname }}/ada.crt
  14. dest: ./tmp/{{ hostvars['ada'].inventory_hostname }}/
  15. flat: yes
  16. delegate_to: "{{ item }}"
  17. loop: "{{ groups['ca'] }}"
  18. - name: Copy key from CA
  19. ansible.builtin.fetch:
  20. src: /etc/nginx/certs/{{ hostvars['ada'].inventory_hostname }}/ada.key
  21. dest: ./tmp/{{ hostvars['ada'].inventory_hostname }}/
  22. flat: yes
  23. delegate_to: "{{ item }}"
  24. loop: "{{ groups['ca'] }}"
  25. - name: Copy to belvedere
  26. ansible.builtin.copy:
  27. src: ./tmp/{{ hostvars['ada'].inventory_hostname }}/
  28. dest: /etc/nginx/certs/{{ hostvars['ada'].inventory_hostname }}/
  29. - name: Delete tmp
  30. file:
  31. path: ./tmp/
  32. state: absent
  33. delegate_to: localhost