main.yml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ---
  2. # tasks file for nebula
  3. - name: get the vagrant network interface and set fact
  4. set_fact:
  5. vagrant_ifce: "ansible_{{ ansible_interfaces | difference(['lo',ansible_default_ipv4.alias]) | sort | first }}"
  6. tags:
  7. - nebula-conf
  8. - name: install built nebula binary
  9. copy: src=../../../../../{{ item }} dest=/usr/local/bin mode=0755
  10. with_items:
  11. - nebula
  12. - nebula-cert
  13. - name: create nebula config directory
  14. file: path="{{ nebula_config_directory }}" state=directory mode=0755
  15. - name: temporarily copy over root.crt and root.key to sign
  16. copy: src={{ item }} dest=/opt/{{ item }}
  17. with_items:
  18. - vagrant-test-ca.key
  19. - vagrant-test-ca.crt
  20. - name: sign using the root key
  21. command: nebula-cert sign -ca-crt /opt/vagrant-test-ca.crt -ca-key /opt/vagrant-test-ca.key -duration 4320h -groups vagrant -ip {{ hostvars[inventory_hostname][vagrant_ifce]['ipv4']['address'] | to_nebula_ip }}/9 -name {{ ansible_hostname }}.nebula -out-crt /etc/nebula/host.crt -out-key /etc/nebula/host.key
  22. - name: remove root.key used to sign
  23. file: dest=/opt/{{ item }} state=absent
  24. with_items:
  25. - vagrant-test-ca.key
  26. - name: write the content of the trusted ca certificate
  27. copy: src="vagrant-test-ca.crt" dest="/etc/nebula/vagrant-test-ca.crt"
  28. notify: restart nebula
  29. - name: Create config directory
  30. file: path="{{ nebula_config_directory }}" owner=root group=root mode=0755 state=directory
  31. - name: nebula config
  32. template: src=config.yml.j2 dest="/etc/nebula/config.yml" mode=0644 owner=root group=root
  33. notify: restart nebula
  34. tags:
  35. - nebula-conf
  36. - name: nebula systemd
  37. copy: src=systemd.nebula.service dest="/etc/systemd/system/nebula.service" mode=0644 owner=root group=root
  38. register: addconf
  39. notify: restart nebula
  40. - name: maybe reload systemd
  41. shell: systemctl daemon-reload
  42. when: addconf.changed
  43. - name: nebula running
  44. service: name="nebula" state=started enabled=yes