How to call infra.controller_configuration.filetree_create with organization filter

Passing organization filter.
Hi everyone, I ma trying to call the file_tree_create role in the infra.controller_configuration collection. My playbook is the same as the example on the info page with the exception of the vars passed below.

If I do not include the organization_filter, the playbook executes successfully. However, running with the organization_filter I get an error that it is not a supported parameter.

# in playbook...
  roles:
    - role: infra.controller_configuration.filetree_create
      input_tag:
        - 'job_templates'
        - 'workflow_job_templates'
        - 'schedules'
      output_path: /tmp/filetree_output
      organization_filter: "Infrastructure Operations"

output:
TASK [infra.controller_configuration.filetree_create : Validating arguments against arg spec 'main' - An Ansible Role to create a local file tree of objects existing in Controller] ***
fatal: [localhost]: FAILED! => {"argument_errors": ["organization_filter. Supported parameters include:...

Is this a bug, or is there a different manner in which I should call this role with the organization_filter parameter?

It’s a pity you chose to show us your [mis]interpretation of the error but not the relevant part of the error itself.

Still — a shot in the dark — if you want to include organization_filter:, then you probably need to include 'organizations' in your input_tag: list (or omit input_tag: altogether and let it default to 'all').

@utoddl, thanks for your [somewhat snarky] response. I apologize for not including the full error. I added organizations to the input_tag as you suggested but still receive the same error. Here is the full error:

TASK [infra.controller_configuration.filetree_create : Validating arguments against arg spec 'main' - An Ansible Role to create a local file tree of objects existing in Controller] ******************
fatal: [localhost]: FAILED! => {"argument_errors": ["organization_filter. Supported parameters include: controller_configuration_async_delay, controller_configuration_async_retries, controller_configuration_filetree_create_secure_logging, controller_configuration_secure_logging, controller_hostname, controller_oauthtoken, controller_password, controller_state, controller_username, controller_validate_certs, input_tag, output_path, query_controller_api_max_objects."], "argument_spec_data": {"controller_configuration_async_delay": {"default": 1, "description": "This variable sets delay between retries across all roles as a default.", "required": false}, "controller_configuration_async_retries": {"default": 30, "description": "This variable sets number of retries across all roles as a default.", "required": false}, "controller_configuration_filetree_create_secure_logging": {"default": false, "description": "Whether or not to include the sensitive tasks from this role in the log. Set this value to `true` if you will be providing your sensitive values from elsewhere.", "required": false, "type": "bool"}, "controller_configuration_secure_logging": {"default": false, "description": "This variable enables secure logging across all roles as a default.", "required": false, "type": "bool"}, "controller_hostname": {"default": "None", "description": "URL to the Ansible Controller Server.", "required": false, "type": "str"}, "controller_oauthtoken": {"default": "None", "description": "Controller Admin User's token on the Ansible Controller Server. This should be stored in an Ansible Vault at or elsewhere and called from a parent playbook. Either username / password or oauthtoken need to be specified.", "required": false, "type": "str"}, "controller_password": {"default": "None", "description": "Controller Admin User's password on the Ansible Controller Server. This should be stored in an Ansible Vault at vars/controller-secrets.yml or elsewhere and called from a parent playbook. Either username / password or oauthtoken need to be specified.", "required": false, "type": "str"}, "controller_state": {"default": "present", "description": "The state all objects will take unless overridden by object default", "required": false, "type": "str"}, "controller_username": {"default": "None", "description": "Admin User on the Ansible Controller Server. Either username / password or oauthtoken need to be specified.", "required": false, "type": "str"}, "controller_validate_certs": {"default": true, "description": "Whether or not to validate the Ansible Controller Server's SSL certificate.", "required": false, "type": "str"}, "input_tag": {"default": ["all"], "description": "The tags which are applied to the 'sub-roles'. If 'all' is in the list (the default value) then all roles will be called.", "elements": "str", "required": false, "type": "list"}, "output_path": {"default": "/tmp/filetree_output", "description": "The path to the output directory where all the generated `yaml` files with the corresponding Objects as code will be written to.", "required": false, "type": "str"}, "query_controller_api_max_objects": {"default": 10000, "description": "Maximum number of objects to return from the list. If a list view returns more an max_objects an exception will be raised", "required": false, "type": "int"}}, "changed": false, "msg": "Validation of arguments failed:\norganization_filter. Supported parameters include: controller_configuration_async_delay, controller_configuration_async_retries, controller_configuration_filetree_create_secure_logging, controller_configuration_secure_logging, controller_hostname, controller_oauthtoken, controller_password, controller_state, controller_username, controller_validate_certs, input_tag, output_path, query_controller_api_max_objects.", "validate_args_context": {"argument_spec_name": "main", "name": "filetree_create", "path": "/home/dave/.ansible/collections/ansible_collections/infra/controller_configuration/roles/filetree_create", "type": "role"}}

The relevant part is this:
“Validation of arguments failed:\norganization_filter. Supported parameters include: controller_configuration_async_delay controller_configuration_async_retries, controller_configuration_filetree_create_secure_logging, controller_configuration_secure_logging, controller_hostname, controller_oauthtoken, controller_password, controller_state, controller_username, controller_validate_certs, input_tag, output_path, query_controller_api_max_objects.”

organization_filter is not on the list of valid arguments, yet it is clearly listed as a Role Variable in the documentation.

Comparing the list of Role Variables to the valid arguments, I noticed that flatten_output is also not supported and remembered there was an example of flatten_output where it is passed in the -e command line parameter in the documentation. I was able to run the following successfully:

ansible-playbook export.yml -e '{organization_filter: "Infrastructure Operations"}'

Forgive my ignorance as I am fairly new to using these modules, but is this common practice for vars to be passed outside of the call to the role (in -e) and not allowed within the call (in the playbook roles: as vars) or is this a bug?

The issue is you’re trying to use a variable as an argument. Most roles expect you to pass vars to the role to set parameters, but some also accept arguments in their argument spec.

roles:
  - role: role_with_vars
    vars:
      organization_filter: my_org
  - role: role_with_args
    organization_filter: my_org

Any argument defined in controller_configuration/roles/filetree_create/meta/argument_specs.yml can be set at the argument level, but anything else must be a variable.

1 Like

Sorry about the snark, @derb . I need to work on my “talking in public to friends I don’t know yet” filter. […] And as I’m typing I see @Denney-tech jumped in with actual information. Cheers!

2 Likes

@utoddl & @Denney-tech,

Thank you both! This helps my understanding immensely!

2 Likes

@derb You’re welcome!

@utoddl I’m sorry if I stole your thunder. :slight_smile:

Not at all! I was sliding down rabbit hole.

I was just going to say, I usually glaze over and hear “parameter”, “variable”, and “argument” as generic speak for “names for values”, but this is a case where the distinctions really matter. This was flying right over my head and I wasn’t going to see it. So thanks for stepping in.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.