ansible-playbook-git.yaml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # Kestra ansible-playbook Template
  2. # ---
  3. #
  4. # Run an ansible playbook cloned from a Git Repository
  5. #
  6. id: ansible_playbook_git
  7. namespace: your_namespace # <-- Replace with your namespace...
  8. tasks:
  9. - id: ansible_job
  10. type: io.kestra.plugin.core.flow.WorkingDirectory
  11. inputFiles:
  12. id_rsa: "{{ secret('RSA_SSH_KEY') }}" # <-- (Required) Replace with your secret key...
  13. # id_ed25519: "{{ secret('ED25519_SSH_KEY') }}" # <-- (Optional) Replace with your secret key, when using ED25519...
  14. tasks:
  15. - id: git_clone
  16. type: io.kestra.plugin.git.Clone
  17. url: your-git-repository-url # <-- Replace with your Git repository URL...
  18. directory: ansible
  19. branch: main # <-- (Optional) Replace with your Git branch...
  20. # --> (Optional) If Git repository is private, add your Git token...
  21. # username: xcad
  22. # password: "{{ secret('GITOKEN') }}"
  23. # <--
  24. - id: ansible_playbook
  25. type: io.kestra.plugin.ansible.cli.AnsibleCLI
  26. taskRunner:
  27. type: io.kestra.plugin.scripts.runner.docker.Docker
  28. image: docker.io/cytopia/ansible:latest-tools
  29. user: "1000" # <-- (Required) Replace with your user id...
  30. env:
  31. "ANSIBLE_HOST_KEY_CHECKING": "false"
  32. "ANSIBLE_REMOTE_USER": "your-remote-user" # <-- (Required) Replace with your remote user...
  33. commands:
  34. - ansible-playbook -i ansible/inventory --key-file id_rsa ansible/your-playbook.yaml
  35. # - ansible-playbook -i ansible/inventory --key-file id_ed25519 ansible/your-playbook.yaml # <-- (Optional) when using ED25519...