mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-06 06:04:24 -07:00
Initial commit
This commit is contained in:
commit
aebc1b03fd
4861 changed files with 812621 additions and 0 deletions
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
- import_tasks: setup_no_value.yml
|
||||
|
||||
- name: testing exclusion between state and list_all parameters
|
||||
git_config:
|
||||
list_all: true
|
||||
state: absent
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: assert git_config failed
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- "result.msg == 'parameters are mutually exclusive: list_all|state'"
|
||||
...
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
- import_tasks: setup_no_value.yml
|
||||
|
||||
- name: setting value without state
|
||||
git_config:
|
||||
name: "{{ option_name }}"
|
||||
value: "{{ option_value }}"
|
||||
scope: "{{ option_scope }}"
|
||||
register: set_result
|
||||
|
||||
- name: getting value without state
|
||||
git_config:
|
||||
name: "{{ option_name }}"
|
||||
scope: "{{ option_scope }}"
|
||||
register: get_result
|
||||
|
||||
- name: assert set changed and value is correct
|
||||
assert:
|
||||
that:
|
||||
- set_result.changed == true
|
||||
- set_result.diff.before == "\n"
|
||||
- set_result.diff.after == option_value + "\n"
|
||||
- get_result.changed == false
|
||||
- get_result.config_value == option_value
|
||||
...
|
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
- import_tasks: setup_no_value.yml
|
||||
|
||||
- name: setting value with state=present
|
||||
git_config:
|
||||
name: "{{ option_name }}"
|
||||
value: "{{ option_value }}"
|
||||
scope: "{{ option_scope }}"
|
||||
state: present
|
||||
register: result
|
||||
|
||||
- name: getting value with state=present
|
||||
git_config:
|
||||
name: "{{ option_name }}"
|
||||
scope: "{{ option_scope }}"
|
||||
state: present
|
||||
register: get_result
|
||||
|
||||
- name: assert set changed and value is correct with state=present
|
||||
assert:
|
||||
that:
|
||||
- set_result.changed == true
|
||||
- set_result.diff.before == "\n"
|
||||
- set_result.diff.after == option_value + "\n"
|
||||
- get_result.changed == false
|
||||
- get_result.config_value == option_value
|
||||
...
|
23
tests/integration/targets/git_config/tasks/main.yml
Normal file
23
tests/integration/targets/git_config/tasks/main.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
# test code for the git_config module
|
||||
|
||||
- name: setup
|
||||
import_tasks: setup.yml
|
||||
|
||||
- block:
|
||||
# testing parameters exclusion: state and list_all
|
||||
- import_tasks: exclusion_state_list-all.yml
|
||||
# testing get/set option without state
|
||||
- import_tasks: get_set_no_state.yml
|
||||
# testing get/set option with state=present
|
||||
- import_tasks: get_set_state_present.yml
|
||||
# testing state=absent without value to delete
|
||||
- import_tasks: unset_no_value.yml
|
||||
# testing state=absent with value to delete
|
||||
- import_tasks: unset_value.yml
|
||||
# testing state=absent with value to delete and a defined value parameter
|
||||
- import_tasks: precedence_between_unset_and_value.yml
|
||||
# testing state=absent with check mode
|
||||
- import_tasks: unset_check_mode.yml
|
||||
when: git_installed is succeeded and git_version.stdout is version(git_version_supporting_includes, ">=")
|
||||
...
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
- import_tasks: setup_value.yml
|
||||
|
||||
- name: unsetting value
|
||||
git_config:
|
||||
name: "{{ option_name }}"
|
||||
scope: "{{ option_scope }}"
|
||||
state: absent
|
||||
value: bar
|
||||
register: unset_result
|
||||
|
||||
- name: getting value
|
||||
git_config:
|
||||
name: "{{ option_name }}"
|
||||
scope: "{{ option_scope }}"
|
||||
register: get_result
|
||||
|
||||
- name: assert unset changed and deleted value
|
||||
assert:
|
||||
that:
|
||||
- unset_result.changed == true
|
||||
- unset_result.diff.before == option_value + "\n"
|
||||
- unset_result.diff.after == "\n"
|
||||
- get_result.config_value == ''
|
||||
...
|
11
tests/integration/targets/git_config/tasks/setup.yml
Normal file
11
tests/integration/targets/git_config/tasks/setup.yml
Normal file
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
- name: verify that git is installed so this test can continue
|
||||
command: which git
|
||||
register: git_installed
|
||||
ignore_errors: yes
|
||||
|
||||
- name: get git version, only newer than {{git_version_supporting_includes}} has includes option
|
||||
shell: "git --version | grep 'git version' | sed 's/git version //'"
|
||||
register: git_version
|
||||
ignore_errors: yes
|
||||
...
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
# ------
|
||||
# set up : deleting gitconfig file
|
||||
- name: set up without value
|
||||
file:
|
||||
path: ~/.gitconfig
|
||||
state: absent
|
||||
...
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
# ------
|
||||
# set up : set gitconfig with value
|
||||
- name: set up with value
|
||||
copy:
|
||||
src: gitconfig
|
||||
dest: ~/.gitconfig
|
||||
...
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
- import_tasks: setup_value.yml
|
||||
|
||||
- name: unsetting value with check mode
|
||||
git_config:
|
||||
name: "{{ option_name }}"
|
||||
scope: "{{ option_scope }}"
|
||||
state: absent
|
||||
check_mode: yes
|
||||
register: unset_result
|
||||
|
||||
- name: getting value
|
||||
git_config:
|
||||
name: "{{ option_name }}"
|
||||
scope: "{{ option_scope }}"
|
||||
register: get_result
|
||||
|
||||
- name: assert unset changed but dit not delete value
|
||||
assert:
|
||||
that:
|
||||
- unset_result.changed == true
|
||||
- unset_result.diff.before == option_value + "\n"
|
||||
- unset_result.diff.after == "\n"
|
||||
- get_result.config_value == option_value
|
||||
...
|
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
- import_tasks: setup_no_value.yml
|
||||
|
||||
- name: unsetting value
|
||||
git_config:
|
||||
name: "{{ option_name }}"
|
||||
scope: "{{ option_scope }}"
|
||||
state: absent
|
||||
register: unset_result
|
||||
|
||||
- name: getting value
|
||||
git_config:
|
||||
name: "{{ option_name }}"
|
||||
scope: "{{ option_scope }}"
|
||||
register: get_result
|
||||
|
||||
- name: assert unsetting didn't change
|
||||
assert:
|
||||
that:
|
||||
- unset_result.changed == false
|
||||
- unset_result.msg == 'no setting to unset'
|
||||
- get_result.config_value == ''
|
||||
...
|
24
tests/integration/targets/git_config/tasks/unset_value.yml
Normal file
24
tests/integration/targets/git_config/tasks/unset_value.yml
Normal file
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
- import_tasks: setup_value.yml
|
||||
|
||||
- name: unsetting value
|
||||
git_config:
|
||||
name: "{{ option_name }}"
|
||||
scope: "{{ option_scope }}"
|
||||
state: absent
|
||||
register: unset_result
|
||||
|
||||
- name: getting value
|
||||
git_config:
|
||||
name: "{{ option_name }}"
|
||||
scope: "{{ option_scope }}"
|
||||
register: get_result
|
||||
|
||||
- name: assert unset changed and deleted value
|
||||
assert:
|
||||
that:
|
||||
- unset_result.changed == true
|
||||
- unset_result.diff.before == option_value + "\n"
|
||||
- unset_result.diff.after == "\n"
|
||||
- get_result.config_value == ''
|
||||
...
|
Loading…
Add table
Add a link
Reference in a new issue