BUG: Can not update project variable when many environments use the same var
Próba aktualizacji zmeinnej jeśli jest kilka environmentów z tą sama zmienną kończy się błędem:
TASK [gitlab_ci : edit project variables] ****************************************************************************************************************
Wednesday 09 November 2022 14:22:13 +0000 (0:00:01.485) 0:00:09.888 ****
[DEPRECATION WARNING]: The default value for 'token_validate' will change from True to False. This feature will be removed from community.hashi_vault in
version 4.0.0. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
skipping: [localhost] => (item=VAULT_USER)
skipping: [localhost] => (item=VAULT_PASSWORD)
skipping: [localhost] => (item=USER)
failed: [localhost] (item=GITLAB_CI_BACKUP_NOTIFY_FAILURE_CONTAINER) => {"_loop_gitlab_project_variable": {"environment_scope": "development", "key": "GITLAB_CI_BACKUP_NOTIFY_FAILURE_CONTAINER", "masked": false, "protected": false, "value": "containers.projects.task.gda.pl/containers/ansible:22.10-ansible-6.5.0-python3"}, "ansible_loop_var": "_loop_gitlab_project_variable", "cache_control": "no-cache", "changed": true, "connection": "close", "content_length": "107", "content_type": "application/json", "date": "Wed, 09 Nov 2022 14:22:14 GMT", "elapsed": 0, "json": {"message": "There are multiple variables with provided parameters. Please use 'filter[environment_scope]'"}, "msg": "Status code was 409 and not [200]: HTTP Error 409: Conflict", "permissions_policy": "geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()", "redirected": false, "server": "nginx", "status": 409, "url": "https://projects.task.gda.pl/api/v4/projects/494/variables/GITLAB_CI_BACKUP_NOTIFY_FAILURE_CONTAINER", "vary": "Origin", "x_content_type_options": "nosniff", "x_frame_options": "SAMEORIGIN", "x_request_id": "01GHECA8YFGN2JNVFEJFPCHNKJ", "x_runtime": "0.038260"}
skipping: [localhost] => (item=GITLAB_CI_BACKUP_RESTORE_CONTAINER)
skipping: [localhost] => (item=GTILAB_CI_ENVIRONMENT_URL)
Rozwiązanie:
Dodać filter do urla
url: "{{ _gitlab_ci_project_variables_api_url }}/{{ _gitlab_ci_existing_project_variable.key }}?filter[environment_scope]={{ _loop_gitlab_project_variable.environment_scope }}"