test.yml 995 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. ---
  2. spec:
  3. inputs:
  4. as:
  5. default: test-ansible
  6. stage:
  7. default: test
  8. root_dir:
  9. default: ${CI_PROJECT_DIR}/ansible
  10. description: 'Root directory for the Ansible config and playbooks.'
  11. project_file:
  12. description: 'Ansible Playbook to run.'
  13. ---
  14. '$[[ inputs.as ]]':
  15. stage: '$[[ inputs.stage ]]'
  16. image:
  17. name: alpine:latest
  18. entrypoint: [""]
  19. variables:
  20. ANSIBLE_DIR: "$[[ inputs.root_dir ]]"
  21. PROJECT_FILE: "$[[ inputs.project_file ]]"
  22. before_script: |
  23. echo "Before → Executing..."
  24. echo "Before → Enter Ansible root directory"
  25. cd ${ANSIBLE_DIR}
  26. script: |
  27. echo "Script → Executing..."
  28. echo "Before → Installing dependencies"
  29. apk add --no-cache ansible-core
  30. echo "Script → Test Ansible Playbooks"
  31. ansible-lint ${PROJECT_FILE}
  32. rules:
  33. - if: |
  34. $CI_PIPELINE_SOURCE == "push" ||
  35. $CI_PIPELINE_SOURCE == "merge_request_event"
  36. changes:
  37. - '$[[ inputs.root_dir ]]/**'