mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
gitlab_project_variable: Allow delete without value (#4150)
* value is not required when state is absent * fix integration test. missing value * fix condition * add changelog fragment * fail fast * try required_if on suboptions * revert * Update plugins/modules/source_control/gitlab/gitlab_project_variable.py Co-authored-by: Felix Fontein <felix@fontein.de> * fix naming in doc * typo in name Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
9322809b3a
commit
69551ac325
3 changed files with 61 additions and 6 deletions
|
@ -227,6 +227,7 @@
|
|||
vars:
|
||||
ACCESS_KEY_ID:
|
||||
environment_scope: testing
|
||||
value: checkmode
|
||||
register: gitlab_project_variable_state
|
||||
|
||||
- name: state must be changed
|
||||
|
@ -242,6 +243,7 @@
|
|||
vars:
|
||||
ACCESS_KEY_ID:
|
||||
environment_scope: testing
|
||||
value: checkmode
|
||||
register: gitlab_project_variable_state
|
||||
|
||||
- name: state must not be changed
|
||||
|
@ -644,3 +646,51 @@
|
|||
- gitlab_project_variable_state.project_variable.untouched|length == 0
|
||||
- gitlab_project_variable_state.project_variable.removed|length == 0
|
||||
- gitlab_project_variable_state.project_variable.updated|length == 0
|
||||
|
||||
- name: throw error when state is present but no value is given
|
||||
gitlab_project_variable:
|
||||
api_url: "{{ gitlab_host }}"
|
||||
api_token: "{{ gitlab_login_token }}"
|
||||
project: "{{ gitlab_project_name }}"
|
||||
variables:
|
||||
- name: delete_me
|
||||
register: gitlab_project_variable_state
|
||||
ignore_errors: yes
|
||||
|
||||
- name: verify fail
|
||||
assert:
|
||||
that:
|
||||
- gitlab_project_variable_state.failed
|
||||
- gitlab_project_variable_state is not changed
|
||||
|
||||
- name: set a new variable to delete it later
|
||||
gitlab_project_variable:
|
||||
api_url: "{{ gitlab_host }}"
|
||||
api_token: "{{ gitlab_login_token }}"
|
||||
project: "{{ gitlab_project_name }}"
|
||||
purge: True
|
||||
variables:
|
||||
- name: delete_me
|
||||
value: ansible
|
||||
register: gitlab_project_variable_state
|
||||
|
||||
- name: verify the change
|
||||
assert:
|
||||
that:
|
||||
- gitlab_project_variable_state.changed
|
||||
|
||||
- name: delete variable without referencing its value
|
||||
gitlab_project_variable:
|
||||
api_url: "{{ gitlab_host }}"
|
||||
api_token: "{{ gitlab_login_token }}"
|
||||
project: "{{ gitlab_project_name }}"
|
||||
state: absent
|
||||
variables:
|
||||
- name: delete_me
|
||||
register: gitlab_project_variable_state
|
||||
|
||||
- name: verify deletion
|
||||
assert:
|
||||
that:
|
||||
- gitlab_project_variable_state.changed
|
||||
- gitlab_project_variable_state.project_variable.removed|length == 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue