4
0

main.yml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # These steps automate the installation guide here:
  2. # https://smallstep.com/docs/sso-ssh/hosts/
  3. # TODO: Figure out how to make this idempotent instead of reinstalling on each run
  4. - name: Bootstrap node to connect to CA
  5. command: "step ca bootstrap --context ssh --ca-url {{ smallstep_ssh_ca_url }} --fingerprint {{ smallstep_ssh_ca_fingerprint }} --force"
  6. # when: smallstep_ssh_installed.changed or smallstep_ssh_force_reinit
  7. - name: Get a host SSH certificate
  8. command: "step ssh certificate --context ssh {{ inventory_hostname }} /etc/ssh/ssh_host_ecdsa_key.pub --host --sign --provisioner=\"Service Account\" --token=\"{{ smallstep_ssh_enrollment_token }}\" --force"
  9. # when: smallstep_ssh_installed.changed or smallstep_ssh_force_reinit
  10. - name: Configure SSHD (will be overwriten by the sshd template in Ansible later)
  11. command: "step ssh config --context ssh --host --set Certificate=ssh_host_ecdsa_key-cert.pub --set Key=ssh_host_ecdsa_key"
  12. # when: smallstep_ssh_installed.changed or smallstep_ssh_force_reinit
  13. - name: Activate SmallStep PAM/NSS modules and nohup sshd
  14. command: "step-ssh activate {{ inventory_hostname }}"
  15. # when: smallstep_ssh_installed.changed or smallstep_ssh_force_reinit
  16. - name: Generate host tags list
  17. set_fact:
  18. smallstep_ssh_host_tags_string: "{{ smallstep_ssh_host_tags | to_json | regex_replace('\\:\\ ','=') | regex_replace('\\{\\\"|,\\ \\\"', ' --tag \"') | regex_replace('[\\[\\]{}]') }}"
  19. - name: Generate command to register
  20. set_fact:
  21. smallstep_ssh_register_string: |
  22. step-ssh-ctl register
  23. --hostname {{ inventory_hostname }}
  24. {% if not smallstep_ssh_host_is_bastion %}--bastion '{{ smallstep_ssh_host_behind_bastion_name|default("") }}'{% endif %}
  25. {% if smallstep_ssh_host_is_bastion %}--is-bastion{% endif %}
  26. {{ smallstep_ssh_host_tags_string }}
  27. - debug: var=smallstep_ssh_register_string
  28. - name: Register host with smallstep
  29. command: "{{ smallstep_ssh_register_string }}"
  30. # when: smallstep_ssh_installed.changed or smallstep_ssh_force_reinit