ansible-aci icon indicating copy to clipboard operation
ansible-aci copied to clipboard

add action_groups for module_defaults

Open akira6592 opened this issue 3 years ago • 4 comments

add action_groups in meta/runtime.yml.

This allows module_defaults group feature. https://docs.ansible.com/ansible/latest/user_guide/playbooks_module_defaults.html#module-defaults-groups

It becomes able to specify common options such as host username and password without specifying per tasks or using environment variables.

---
- hosts: apic
  gather_facts: no

  module_defaults:
    group/cisco.aci.aci:
      host: "{{ ansible_host }}"
      username: "{{ username }}"
      password: "{{ password }}"

  tasks:
    - name: create tenant
      cisco.aci.aci_tenant:
        tenant: test_tenant01
        state: present

    - name: create ap
      cisco.aci.aci_ap:
        tenant: test_tenant01
        ap: test_ap01
        state: present

akira6592 avatar Sep 19 '22 13:09 akira6592

Thank you for your approval!

akira6592 avatar Sep 30 '22 23:09 akira6592

One thing I noticed is that in this PR you have a non-standard module on the list aci_bulk_static_binding_to_epg. Probably needs cleanup before merge.

rafmuller avatar Oct 01 '22 23:10 rafmuller

@rafmuller The following modules including aci_bulk_static_binding_to_epg have been merged into the main branch since the version 2.2.0 release.

  • aci_bulk_static_binding_to_epg #228
  • aci_ntp_policy #229
  • aci_ntp_server #229

Therefore, these modules should be included in the list in the next release.

akira6592 avatar Oct 02 '22 11:10 akira6592

Added the following modules that were added after submitting this PR.

  • aci_aaa_ssh_auth
  • aci_aaa_user_domain
  • aci_aaa_user_role
  • aci_l3out_logical_interface_profile_ospf_policy

akira6592 avatar Oct 15 '22 05:10 akira6592

@akira6592 is there a way to just have a wildcard? This looks like it will be a pain to manage this list.

lhercot avatar Oct 17 '22 15:10 lhercot

@akira6592 Have you seen my question above?

lhercot avatar Oct 24 '22 18:10 lhercot

@lhercot Sorry for the delay in replying.

Unfortunately there does not seem to be a way to specify a module with wildcards.

Other collections (e.g., amazon.aws) also maintain listings.

If there is a workaround, it would be to add an explanation in the Contributing to this collection section of the README.md, something like "When adding a module, also add it to meta/runtime.yml".

akira6592 avatar Oct 25 '22 05:10 akira6592

Thanks for the contribution!

To avoid having to manually modify the list, I have added a small function to our release script (which also build our changelog for new releases) which compile the list and output it in the meta/runtime.yml file.

You can see more details here: https://github.com/ciscoecosystem/release_script/commit/4f693d3e41d568bb4737fdd70859a3d7953027e6

lhercot avatar Jan 21 '23 20:01 lhercot

Thank you for merging and adding the process to generate action_groups.

akira6592 avatar Jan 22 '23 03:01 akira6592

FYI, we have decided to rename the group to all so it will be group/cisco.aci.all which will be more logical if we decide to introduce other groups and avoid the repetition.

lhercot avatar Jan 23 '23 22:01 lhercot