isaackehle / ansible-oracle-client

Script to setup Oracle client/library files
MIT License
4 stars 2 forks source link

Ansible "flags" variable #4

Open jdonnerstag opened 6 years ago

jdonnerstag commented 6 years ago

Hi,

this is not an issue but rather a question.

I see you are using the flags variable in tasks/main.yml. I can validate the variable exists but couldn't find any reference to it in the Ansible docs or by searching google. Could you give me a hint when that variable is set and how?

thanks a lot Juergen

isaackehle commented 6 years ago

Yes. You probably know of some of the limitations (or, expected behavior) of tags for ansible. When you include a role in a playbook and assign the tags value, the tags get applied throughout the included role.

This is in contrast with a different expected operation: create a playbook to include a role that runs only a specific set of tags.

Essentially, I would want to use a set of 'outer' playbooks that call specific roles in specific ways to run specific tasks in the roles. So in my implementation of other of my roles, I have playbooks that list out specific flags that I want to use for the playbook. It's a way for me to run a specific playbook without remember the exact flags needed, or to call in other playbooks, passing the flags down from the cli.

For example: pgkehle.ssl-certs

Playbooks:

- name: Create CSR
  hosts: all
  remote_user: root
  gather_facts: ansible_host != 'localhost'

  vars:
    ca_name:          "incommon"

  roles:
    # look for the best .pem file to use, personal or group
    - { role: pgkehle.common, tags: ['always'] }
    # prepare `sc_common_name`, `sc_domain_comp`, etc
    - { role: ../roles/cert_defs }
    # Create the CSR
    - { role: pgkehle.ssl-certs, flags: ['csr_create'] }
- name: Pull the CSR
  hosts: all
  remote_user: root
  gather_facts: ansible_host != 'localhost'

  vars:
    ca_name:          "incommon"

  roles:
    - { role: pgkehle.common, tags: ['always'] }
    - { role: ../roles/cert_defs }
    - { role: pgkehle.ssl-certs, flags: ['csr_pull'] }

If you know of other ways to do this, please let me know! 😄