playbook-inline.yaml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ---
  2. # Kestra ansible-playbook Template
  3. # ---
  4. #
  5. # Run an ansible playbook defined inline the kestra flow.
  6. #
  7. id: ansible_job
  8. namespace: # your-namespace
  9. tasks:
  10. - id: ansible
  11. type: io.kestra.plugin.core.flow.WorkingDirectory
  12. tasks:
  13. - id: local_files
  14. type: io.kestra.core.tasks.storages.LocalFiles
  15. inputs:
  16. inventory.ini: |
  17. srv-demo-1.home.clcreative.de
  18. # --> replace with your playbook
  19. myplaybook.yaml: |
  20. ---
  21. - hosts: srv-demo-1.home.clcreative.de
  22. tasks:
  23. - name: upgrade apt packages
  24. become: true
  25. ansible.builtin.apt:
  26. upgrade: true
  27. update_cache: true
  28. # <--
  29. id_rsa: "{{ secret('SSH_KEY') }}"
  30. - id: ansible_task
  31. type: io.kestra.plugin.ansible.cli.AnsibleCLI
  32. docker:
  33. image: docker.io/cytopia/ansible:latest-tools
  34. user: "1000" # required to set ssh key permissions
  35. env:
  36. "ANSIBLE_HOST_KEY_CHECKING": "false"
  37. # --> (optional) when using a different remote user
  38. # "ANSIBLE_REMOTE_USER": "your-remote-user"
  39. # <--
  40. commands:
  41. - ansible-playbook -i inventory.ini --key-file id_rsa myplaybook.yaml