playbook-ssh-key.yaml 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. ---
  2. # Kestra ansible-playbook Template
  3. # ---
  4. #
  5. # Run an ansible playbook which has been uploaded to the server, using
  6. # ssh key authentication.
  7. #
  8. id: ansible_job
  9. namespace: # your-namespace
  10. tasks:
  11. - id: ansible
  12. type: io.kestra.plugin.core.flow.WorkingDirectory
  13. tasks:
  14. - id: load_ssh_key
  15. type: io.kestra.core.tasks.storages.LocalFiles
  16. inputs:
  17. id_rsa: "{{ secret('SSH_KEY') }}"
  18. - id: ansible_task
  19. namespaceFiles:
  20. enabled: true
  21. # --> upload your files to the kestra data directory for the namespace in
  22. # <docker volume for kestra-data>/<namespace>/_files/
  23. include:
  24. - inventory.ini
  25. - myplaybook.yaml
  26. # <--
  27. type: io.kestra.plugin.ansible.cli.AnsibleCLI
  28. docker:
  29. image: docker.io/cytopia/ansible:latest-tools
  30. user: "1000" # required to set ssh key permissions
  31. env:
  32. "ANSIBLE_HOST_KEY_CHECKING": "false"
  33. # --> (optional) when using a different remote user
  34. # "ANSIBLE_REMOTE_USER": "your-remote-user"
  35. # <--
  36. commands:
  37. - ansible-playbook -i inventory.ini --key-file id_rsa myplaybook.yaml