kestra-io / plugin-ansible

Apache License 2.0
1 stars 2 forks source link

namespaceFiles include/exclude not taking effect #26

Open shrutimantri opened 2 months ago

shrutimantri commented 2 months ago

Expected Behavior

namespaceFiles include/exclude should take effect.

Actual Behaviour

I am using two namespace files:

inventory.ini

localhost ansible_connection=local

playbook.yml

---
- hosts: localhost
  tasks:
    - name: Print Hello World
      debug:
        msg: "Hello, World!"

Now, none of the following workflows should ideally work, but all of them work.

id: ansible
namespace: company.team

tasks:
  - id: ansible_task
    type: io.kestra.plugin.ansible.cli.AnsibleCLI
    namespaceFiles:
      enabled: true
      exclude: 
        - "playbook.yml"
    inputFiles:
      inventory.ini: "{{ read('inventory.ini') }}"
      myplaybook.yml: "{{ read('playbook.yml') }}"
    docker:
      image: cytopia/ansible:latest-tools
    commands:
      - ansible-playbook -i inventory.ini myplaybook.yml
id: ansible
namespace: company.team

tasks:
  - id: ansible_task
    type: io.kestra.plugin.ansible.cli.AnsibleCLI
    namespaceFiles:
      enabled: true
      include: 
        - "playbook.yml"
    inputFiles:
      inventory.ini: "{{ read('inventory.ini') }}"
      myplaybook.yml: "{{ read('playbook.yml') }}"
    docker:
      image: cytopia/ansible:latest-tools
    commands:
      - ansible-playbook -i inventory.ini myplaybook.yml
id: ansible
namespace: company.team

tasks:
  - id: ansible_task
    type: io.kestra.plugin.ansible.cli.AnsibleCLI
    namespaceFiles:
      enabled: true
      exclude: 
        - "*.yml"
    inputFiles:
      inventory.ini: "{{ read('inventory.ini') }}"
      myplaybook.yml: "{{ read('playbook.yml') }}"
    docker:
      image: cytopia/ansible:latest-tools
    commands:
      - ansible-playbook -i inventory.ini myplaybook.yml

Steps To Reproduce

  1. Try include/exclude for any files used by the ansible flow.
  2. The flow will work. Ideally, the flow should not find the excluded / not included file(s), and error out.

Environment Information

Example flow

id: ansible
namespace: company.team

tasks:
  - id: ansible_task
    type: io.kestra.plugin.ansible.cli.AnsibleCLI
    namespaceFiles:
      enabled: true
      exclude: 
        - "playbook.yml"
    inputFiles:
      inventory.ini: "{{ read('inventory.ini') }}"
      myplaybook.yml: "{{ read('playbook.yml') }}"
    docker:
      image: cytopia/ansible:latest-tools
    commands:
      - ansible-playbook -i inventory.ini myplaybook.yml

Flow should error out, but it works.

anna-geller commented 2 months ago

hey Shruti, reading files via the read() function to read the content of namespace files will always work across all plugins. The include/exclude pattern is only intended when injecting namespace files directly into the task's working directory. If this is not clear enough in the current documentation of the namespaceFiles property, can you add a PR that would clarify that property documentation and make that PR close this issue?