osism / documentation

OSISM documentation
https://docs.osism.tech
Creative Commons Attribution Share Alike 4.0 International
12 stars 16 forks source link

Ansible style guide: Usage of collections or FQCN´s #374

Closed ra-beer closed 2 years ago

ra-beer commented 2 years ago

There are two ways to declare the ansible modules. First way you can write it out like this one:

- name: Configure netbox manufacturers
  netbox.netbox.netbox_manufacturer:
    netbox_url: "{{ netbox_url }}"
    netbox_token: "{{ netbox_token }}"
    data:
      name: "{{ item.value.name }}"
      slug: "{{ item.value.slug }}"
      description: "{{ item.value.description | default('') }}"
    state: present
  with_dict: "{{ netbox_data_manufacturers }}"

Or you can declare the collection like this:

collections:
    - netbox.netbox

  tasks:
    - name: Manage Discworld site
      netbox_site:
        netbox_url: "{{ netbox_url }}"
        netbox_token: "{{ netbox_token }}"
        validate_certs: false
        data:
          name: Discworld
          slug: discworld
        state: present

We should declare one way that fits for us. We shouldn´t use both ways.

berendt commented 2 years ago

We wanted to do it as shown in the first example. Please add in the style guide.

We should then also add a custom rule in Ansible Lint to check this in the future. We can do this in a separate issue.