gitlab_project_variable: added support for variable_type (#181)

* gitlab_project_variable: added support for variable_type

* gitlab_project_variable: Added integration tests for variable_type file.

* Changed test case variable name, ansible was masking the output.
This commit is contained in:
Alvaro A 2020-05-25 12:18:19 +02:00 committed by GitHub
commit ece18b756b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 92 additions and 8 deletions

View file

@ -142,6 +142,7 @@
value: checkmode
masked: True
protected: True
variable_type: env_var
register: gitlab_project_variable_state
- name: state must be changed
@ -159,6 +160,7 @@
value: checkmode
masked: True
protected: True
variable_type: env_var
register: gitlab_project_variable_state
- name: state must not be changed
@ -413,6 +415,80 @@
- gitlab_project_variable_state.project_variable.updated|length == 0
- gitlab_project_variable_state.project_variable.removed[0] == "some"
- name: add one variable with variable_type file
gitlab_project_variable:
api_url: "{{ gitlab_host }}"
api_token: "{{ gitlab_login_token }}"
project: "{{ gitlab_project_name }}"
vars:
my_test_var:
value: my_test_value
variable_type: file
purge: False
register: gitlab_project_variable_state
- name: append one variable state must be changed
assert:
that:
- gitlab_project_variable_state.changed
- gitlab_project_variable_state.project_variable.added|length == 1
- 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
- gitlab_project_variable_state.project_variable.added[0] == "my_test_var"
- name: change variable_type attribute
gitlab_project_variable:
api_url: "{{ gitlab_host }}"
api_token: "{{ gitlab_login_token }}"
project: "{{ gitlab_project_name }}"
vars:
my_test_var:
value: my_test_value
variable_type: env_var
register: gitlab_project_variable_state
- name: state must be changed
assert:
that:
- gitlab_project_variable_state is changed
- name: revert variable_type attribute
gitlab_project_variable:
api_url: "{{ gitlab_host }}"
api_token: "{{ gitlab_login_token }}"
project: "{{ gitlab_project_name }}"
vars:
my_test_var:
value: my_test_value
variable_type: file
register: gitlab_project_variable_state
- name: state must be changed
assert:
that:
- gitlab_project_variable_state is changed
- name: delete the variable_type file variable
gitlab_project_variable:
api_url: "{{ gitlab_host }}"
api_token: "{{ gitlab_login_token }}"
project: "{{ gitlab_project_name }}"
state: absent
vars:
my_test_var: my_test_value
register: gitlab_project_variable_state
- name: no variable is left state must be changed
assert:
that:
- gitlab_project_variable_state.changed
- gitlab_project_variable_state.project_variable.added|length == 0
- gitlab_project_variable_state.project_variable.untouched|length == 0
- gitlab_project_variable_state.project_variable.removed|length == 1
- gitlab_project_variable_state.project_variable.updated|length == 0
- gitlab_project_variable_state.project_variable.removed[0] == "my_test_var"
- name: check that no variables are left
gitlab_project_variable:
api_url: "{{ gitlab_host }}"