Skip to content

Commit

Permalink
fix missing 'default()' clause (#20)
Browse files Browse the repository at this point in the history
* fix missing 'default()' clause

* updated .gitignore

* fixed malformed string to get /access_list

* fixed malformed string to get /access_list

* fixed linting

* added changelog fragment. fixed linting

* fixed linting

* removed changelog fragment for feature_change, which is not allowed
  • Loading branch information
ivarmu authored Oct 30, 2024
1 parent d69106b commit a9c674e
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
collections/*
!collections/requirements.yml
ansible_collections
*.tar.gz
*.pyc
id_rsa*
test
tests/output
.vscode
ansible.cfg
vault-aap-controller.yaml
4 changes: 0 additions & 4 deletions changelogs/fragments/fiiletree_export_access_list.yml

This file was deleted.

4 changes: 4 additions & 0 deletions changelogs/fragments/filetree_create_role_issues.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
bugfixes:
- filetree_create roles export issues introduced by PR #14
...
13 changes: 9 additions & 4 deletions roles/filetree_create/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ The following variables are required for that role to work properly:
| `templates_overrides_resources`| N/A | no | dict | Whether the certain objects should be modified during the export |
| `templates_overrides_global`| N/A | no | dict | Whether the all objects should be modified during the export |


## Dependencies

A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.

## Example Playbook - export everything without modifications

```yaml
---
- hosts: all
Expand Down Expand Up @@ -90,6 +90,7 @@ A list of other roles hosted on Galaxy should go here, plus any details in regar
when: controller_oauthtoken_url is defined
...
```

This role can generate output files in two different ways:

- **Structured output**:
Expand Down Expand Up @@ -207,10 +208,13 @@ ansible-playbook infra.aap_configuration_extended.flatten_filetree_create_output
```

## Example Playbook - export object with modifications

This example will export all object but some with modifications:
- job template called `job_template_example` will be exported with the `dev` branch, while the rest of the job templates will use the `main` branch — the resources dictionary takes precedence over the global dictionary.
- all projects will have a Jinja2 expression assigned to the `scm_branch`.
- all schedules enabled state will be set as `false`.

- job template called `job_template_example` will be exported with the `dev` branch, while the rest of the job templates will use the `main` branch — the resources dictionary takes precedence over the global dictionary.
- all projects will have a Jinja2 expression assigned to the `scm_branch`.
- all schedules enabled state will be set as `false`.

```yaml
---
- hosts: all
Expand Down Expand Up @@ -240,6 +244,7 @@ This example will export all object but some with modifications:

...
```

## License

GPLv3+
Expand Down
2 changes: 1 addition & 1 deletion roles/filetree_create/tasks/notification_templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
dest: "{{ __dest }}"
mode: '0644'
vars:
__dest: "{{ output_path }}/{{ (current_notification_templates_asset_value.summary_fields.organization.name |default(organization, true)) | regex_replace('/', '_') }}/notification_templates/{{ current_notification_templates_asset_value.name | regex_replace('/', '_') }}.yaml"
__dest: "{{ output_path }}/{{ (current_notification_templates_asset_value.summary_fields.organization.name | default(organization, true)) | regex_replace('/', '_') }}/notification_templates/{{ current_notification_templates_asset_value.name | regex_replace('/', '_') }}.yaml"
loop: "{{ notification_templates_lookvar }}"
loop_control:
loop_var: current_notification_templates_asset_value
Expand Down
2 changes: 1 addition & 1 deletion roles/filetree_create/tasks/team_access_list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

- name: "Get access list for object from the API"
ansible.builtin.set_fact:
access_lookvar: "{{ query(controller_api_plugin, 'api/v2/' + {{ object_type }} + '/' + {{ object_id }} + '/access_list',
access_lookvar: "{{ query(controller_api_plugin, 'api/v2/' + object_type + '/' + object_id + '/access_list',
host=controller_hostname, oauth_token=controller_oauthtoken, verify_ssl=controller_validate_certs,
return_all=true, max_objects=query_controller_api_max_objects)
}}"
Expand Down
2 changes: 1 addition & 1 deletion roles/filetree_create/tasks/user_access_list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

- name: "Get access list for object from the API"
ansible.builtin.set_fact:
access_lookvar: "{{ query(controller_api_plugin, 'api/v2/' + {{ object_type }} + '/' + {{ object_id }} + '/access_list',
access_lookvar: "{{ query(controller_api_plugin, 'api/v2/' + object_type + '/' + object_id + '/access_list',
host=controller_hostname, oauth_token=controller_oauthtoken, verify_ssl=controller_validate_certs,
return_all=true, max_objects=query_controller_api_max_objects)
}}"
Expand Down
2 changes: 1 addition & 1 deletion roles/filetree_create/templates/current_hosts.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ controller_hosts:
or (host.variables and host.variables != '---' and host.variables != '') %}
variables:
{{ template_overrides_resources.host[host.name].variables
| template_overrides_global.host.variables
| default(template_overrides_global.host.variables)
| default(host.variables)
| from_yaml | to_nice_yaml(indent=2) | indent(width=6, first=False) | replace("'{{", "!unsafe \'{{") }}
{%- endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ controller_roles:
{% endif %}
role: "{% if team_role.role | lower == 'approve' %}approval{% else %}{{ team_role.role | lower | regex_replace(' ', '_') }}{% endif %}"
...

0 comments on commit a9c674e

Please sign in to comment.