diff --git a/test/integration/targets/docker_swarm/aliases b/test/integration/targets/docker_swarm/aliases index 2b3832dde58..47a4e975b6a 100644 --- a/test/integration/targets/docker_swarm/aliases +++ b/test/integration/targets/docker_swarm/aliases @@ -2,3 +2,9 @@ shippable/posix/group2 skip/osx skip/freebsd destructive +skip/docker # The tests sometimes make docker daemon unstable; hence, + # we skip all docker-based CI runs to avoid disrupting + # the whole CI system. On VMs, we restart docker daemon + # after finishing the tests to minimize potential effects + # on other tests. +needs/root diff --git a/test/integration/targets/docker_swarm/meta/main.yml b/test/integration/targets/docker_swarm/meta/main.yml index 07da8c6ddae..078660a8abb 100644 --- a/test/integration/targets/docker_swarm/meta/main.yml +++ b/test/integration/targets/docker_swarm/meta/main.yml @@ -1,3 +1,4 @@ --- dependencies: - setup_docker + - setup_openssl diff --git a/test/integration/targets/docker_swarm/tasks/main.yml b/test/integration/targets/docker_swarm/tasks/main.yml index 04d8cef9127..87c7eac8c23 100644 --- a/test/integration/targets/docker_swarm/tasks/main.yml +++ b/test/integration/targets/docker_swarm/tasks/main.yml @@ -6,6 +6,21 @@ - "tests/*.yml" always: + - name: Cleanup (trying) + docker_swarm: + state: absent + force: true + diff: no + ignore_errors: yes + + - name: Restart docker daemon + service: + name: docker + state: restarted + become: yes + - name: Wait for docker daemon to be fully restarted + command: docker ps + - name: Cleanup docker_swarm: state: absent diff --git a/test/integration/targets/docker_swarm/tasks/tests/options-ca.yml b/test/integration/targets/docker_swarm/tasks/tests/options-ca.yml new file mode 100644 index 00000000000..f88e5510130 --- /dev/null +++ b/test/integration/targets/docker_swarm/tasks/tests/options-ca.yml @@ -0,0 +1,138 @@ +--- +- block: + - name: Generate privatekey + openssl_privatekey: + path: "{{ output_dir }}/ansible_{{ key }}.key" + size: 2048 + mode: "0666" + loop: + - key1 + - key2 + loop_control: + loop_var: key + + - name: Generate CSR + openssl_csr: + path: "{{ output_dir }}/ansible_{{ key }}.csr" + privatekey_path: "{{ output_dir }}/ansible_{{ key }}.key" + basic_constraints: + - "CA:TRUE" + key_usage: + - keyCertSign + loop: + - key1 + - key2 + loop_control: + loop_var: key + + - name: Generate self-signed certificate + openssl_certificate: + path: "{{ output_dir }}/ansible_{{ key }}.pem" + privatekey_path: "{{ output_dir }}/ansible_{{ key }}.key" + csr_path: "{{ output_dir }}/ansible_{{ key }}.csr" + provider: selfsigned + loop: + - key1 + - key2 + loop_control: + loop_var: key + + ################################################################### + ## signing_ca_cert and signing_ca_key ############################# + ################################################################### + - name: signing_ca_cert and signing_ca_key (check mode) + docker_swarm: + advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}" + state: present + signing_ca_cert: "{{ lookup('file', role_path ~ '/' ~ output_dir ~ '/ansible_key1.pem') }}" + signing_ca_key: "{{ lookup('file', role_path ~ '/' ~ output_dir ~ '/ansible_key1.key') }}" + timeout: 120 + check_mode: yes + diff: yes + register: output_1 + + - name: signing_ca_cert and signing_ca_key + docker_swarm: + advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}" + state: present + signing_ca_cert: "{{ lookup('file', role_path ~ '/' ~ output_dir ~ '/ansible_key1.pem') }}" + signing_ca_key: "{{ lookup('file', role_path ~ '/' ~ output_dir ~ '/ansible_key1.key') }}" + timeout: 120 + diff: yes + register: output_2 + + - name: Private key + debug: msg="{{ lookup('file', role_path ~ '/' ~ output_dir ~ '/ansible_key1.key') }}" + - name: Cert + debug: msg="{{ lookup('file', role_path ~ '/' ~ output_dir ~ '/ansible_key1.pem') }}" + + # Idempotence for CA cert and key don't work yet! FIXME + + #- name: signing_ca_cert and signing_ca_key (idempotent) + # docker_swarm: + # state: present + # signing_ca_cert: "{{ lookup('file', role_path ~ '/' ~ output_dir ~ '/ansible_key1.pem') }}" + # signing_ca_key: "{{ lookup('file', role_path ~ '/' ~ output_dir ~ '/ansible_key1.key') }}" + # timeout: 120 + # diff: yes + # register: output_3 + + #- name: signing_ca_cert and signing_ca_key (idempotent, check mode) + # docker_swarm: + # state: present + # signing_ca_cert: "{{ lookup('file', role_path ~ '/' ~ output_dir ~ '/ansible_key1.pem') }}" + # signing_ca_key: "{{ lookup('file', role_path ~ '/' ~ output_dir ~ '/ansible_key1.key') }}" + # timeout: 120 + # check_mode: yes + # diff: yes + # register: output_4 + + - name: signing_ca_cert and signing_ca_key (change, check mode) + docker_swarm: + state: present + signing_ca_cert: "{{ lookup('file', role_path ~ '/' ~ output_dir ~ '/ansible_key2.pem') }}" + signing_ca_key: "{{ lookup('file', role_path ~ '/' ~ output_dir ~ '/ansible_key2.key') }}" + timeout: 120 + check_mode: yes + diff: yes + register: output_5 + + - name: signing_ca_cert and signing_ca_key (change) + docker_swarm: + state: present + signing_ca_cert: "{{ lookup('file', role_path ~ '/' ~ output_dir ~ '/ansible_key2.pem') }}" + signing_ca_key: "{{ lookup('file', role_path ~ '/' ~ output_dir ~ '/ansible_key2.key') }}" + timeout: 120 + diff: yes + register: output_6 + + - name: assert signing_ca_cert and signing_ca_key + assert: + that: + - 'output_1 is changed' + - 'output_1.actions[0] | regex_search("New Swarm cluster created: ")' + - 'output_1.diff.before is defined' + - 'output_1.diff.after is defined' + - 'output_2 is changed' + - 'output_2.actions[0] | regex_search("New Swarm cluster created: ")' + - 'output_2.diff.before is defined' + - 'output_2.diff.after is defined' + #- 'output_3 is not changed' + #- 'output_3.actions[0] == "No modification"' + #- 'output_3.diff.before is defined' + #- 'output_3.diff.after is defined' + #- 'output_4 is not changed' + #- 'output_4.actions[0] == "No modification"' + #- 'output_4.diff.before is defined' + #- 'output_4.diff.after is defined' + - 'output_5 is changed' + - 'output_5.actions[0] == "Swarm cluster updated"' + - 'output_5.diff.before is defined' + - 'output_5.diff.after is defined' + - 'output_6 is changed' + - 'output_6.actions[0] == "Swarm cluster updated"' + - 'output_6.diff.before is defined' + - 'output_6.diff.after is defined' + + # https://github.com/ansible/ansible/issues/34054: openssl_certificate unusable on RHEL 7 + when: pyopenssl_version.stdout is version('0.15', '>=') diff --git a/test/integration/targets/docker_swarm/tasks/tests/options.yml b/test/integration/targets/docker_swarm/tasks/tests/options.yml new file mode 100644 index 00000000000..d7c00bdb50c --- /dev/null +++ b/test/integration/targets/docker_swarm/tasks/tests/options.yml @@ -0,0 +1,1008 @@ +--- +- name: Create a Swarm cluster + docker_swarm: + state: present + advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}" + name: default + diff: yes + +#################################################################### +## autolock_managers ############################################### +#################################################################### + +- name: autolock_managers (check mode) + docker_swarm: + state: present + autolock_managers: yes + check_mode: yes + diff: yes + register: output_1 + +- name: autolock_managers + docker_swarm: + state: present + autolock_managers: yes + diff: yes + register: output_2 + +- name: autolock_managers (idempotent) + docker_swarm: + state: present + autolock_managers: yes + diff: yes + register: output_3 + +- name: autolock_managers (idempotent, check mode) + docker_swarm: + state: present + autolock_managers: yes + check_mode: yes + diff: yes + register: output_4 + +- name: autolock_managers (change, check mode) + docker_swarm: + state: present + autolock_managers: no + check_mode: yes + diff: yes + register: output_5 + +- name: autolock_managers (change) + docker_swarm: + state: present + autolock_managers: no + diff: yes + register: output_6 + +- name: assert changed when remove a swarm cluster + assert: + that: + - 'output_1 is changed' + - 'output_1.actions[0] == "Swarm cluster updated"' + - 'output_1.diff.before is defined' + - 'output_1.diff.after is defined' + - 'output_2 is changed' + - 'output_2.actions[0] == "Swarm cluster updated"' + - 'output_2.diff.before is defined' + - 'output_2.diff.after is defined' + - 'output_3 is not changed' + - 'output_3.actions[0] == "No modification"' + - 'output_3.diff.before is defined' + - 'output_3.diff.after is defined' + - 'output_4 is not changed' + - 'output_4.actions[0] == "No modification"' + - 'output_4.diff.before is defined' + - 'output_4.diff.after is defined' + - 'output_5 is changed' + - 'output_5.actions[0] == "Swarm cluster updated"' + - 'output_5.diff.before is defined' + - 'output_5.diff.after is defined' + - 'output_6 is changed' + - 'output_6.actions[0] == "Swarm cluster updated"' + - 'output_6.diff.before is defined' + - 'output_6.diff.after is defined' + +#################################################################### +## ca_force_rotate ################################################# +#################################################################### + +- name: ca_force_rotate (check mode) + docker_swarm: + state: present + ca_force_rotate: 1 + check_mode: yes + diff: yes + register: output_1 + +- name: ca_force_rotate + docker_swarm: + state: present + ca_force_rotate: 1 + diff: yes + register: output_2 + +- name: ca_force_rotate (idempotent) + docker_swarm: + state: present + ca_force_rotate: 1 + diff: yes + register: output_3 + +- name: ca_force_rotate (idempotent, check mode) + docker_swarm: + state: present + ca_force_rotate: 1 + check_mode: yes + diff: yes + register: output_4 + +- name: ca_force_rotate (change, check mode) + docker_swarm: + state: present + ca_force_rotate: 0 + check_mode: yes + diff: yes + register: output_5 + +- name: ca_force_rotate (change) + docker_swarm: + state: present + ca_force_rotate: 0 + diff: yes + register: output_6 + +- name: assert changed when remove a swarm cluster + assert: + that: + - 'output_1 is changed' + - 'output_1.actions[0] == "Swarm cluster updated"' + - 'output_1.diff.before is defined' + - 'output_1.diff.after is defined' + - 'output_2 is changed' + - 'output_2.actions[0] == "Swarm cluster updated"' + - 'output_2.diff.before is defined' + - 'output_2.diff.after is defined' + - 'output_3 is not changed' + - 'output_3.actions[0] == "No modification"' + - 'output_3.diff.before is defined' + - 'output_3.diff.after is defined' + - 'output_4 is not changed' + - 'output_4.actions[0] == "No modification"' + - 'output_4.diff.before is defined' + - 'output_4.diff.after is defined' + - 'output_5 is changed' + - 'output_5.actions[0] == "Swarm cluster updated"' + - 'output_5.diff.before is defined' + - 'output_5.diff.after is defined' + - 'output_6 is changed' + - 'output_6.actions[0] == "Swarm cluster updated"' + - 'output_6.diff.before is defined' + - 'output_6.diff.after is defined' + +#################################################################### +## dispatcher_heartbeat_period ##################################### +#################################################################### + +- name: dispatcher_heartbeat_period (check mode) + docker_swarm: + state: present + dispatcher_heartbeat_period: 10 + check_mode: yes + diff: yes + register: output_1 + +- name: dispatcher_heartbeat_period + docker_swarm: + state: present + dispatcher_heartbeat_period: 10 + diff: yes + register: output_2 + +- name: dispatcher_heartbeat_period (idempotent) + docker_swarm: + state: present + dispatcher_heartbeat_period: 10 + diff: yes + register: output_3 + +- name: dispatcher_heartbeat_period (idempotent, check mode) + docker_swarm: + state: present + dispatcher_heartbeat_period: 10 + check_mode: yes + diff: yes + register: output_4 + +- name: dispatcher_heartbeat_period (change, check mode) + docker_swarm: + state: present + dispatcher_heartbeat_period: 23 + check_mode: yes + diff: yes + register: output_5 + +- name: dispatcher_heartbeat_period (change) + docker_swarm: + state: present + dispatcher_heartbeat_period: 23 + diff: yes + register: output_6 + +- name: assert changed when remove a swarm cluster + assert: + that: + - 'output_1 is changed' + - 'output_1.actions[0] == "Swarm cluster updated"' + - 'output_1.diff.before is defined' + - 'output_1.diff.after is defined' + - 'output_2 is changed' + - 'output_2.actions[0] == "Swarm cluster updated"' + - 'output_2.diff.before is defined' + - 'output_2.diff.after is defined' + - 'output_3 is not changed' + - 'output_3.actions[0] == "No modification"' + - 'output_3.diff.before is defined' + - 'output_3.diff.after is defined' + - 'output_4 is not changed' + - 'output_4.actions[0] == "No modification"' + - 'output_4.diff.before is defined' + - 'output_4.diff.after is defined' + - 'output_5 is changed' + - 'output_5.actions[0] == "Swarm cluster updated"' + - 'output_5.diff.before is defined' + - 'output_5.diff.after is defined' + - 'output_6 is changed' + - 'output_6.actions[0] == "Swarm cluster updated"' + - 'output_6.diff.before is defined' + - 'output_6.diff.after is defined' + +#################################################################### +## election_tick ################################################### +#################################################################### + +- name: election_tick (check mode) + docker_swarm: + state: present + election_tick: 20 + check_mode: yes + diff: yes + register: output_1 + +- name: election_tick + docker_swarm: + state: present + election_tick: 20 + diff: yes + register: output_2 + +- name: election_tick (idempotent) + docker_swarm: + state: present + election_tick: 20 + diff: yes + register: output_3 + +- name: election_tick (idempotent, check mode) + docker_swarm: + state: present + election_tick: 20 + check_mode: yes + diff: yes + register: output_4 + +- name: election_tick (change, check mode) + docker_swarm: + state: present + election_tick: 5 + check_mode: yes + diff: yes + register: output_5 + +- name: election_tick (change) + docker_swarm: + state: present + election_tick: 5 + diff: yes + register: output_6 + +- name: assert changed when remove a swarm cluster + assert: + that: + - 'output_1 is changed' + - 'output_1.actions[0] == "Swarm cluster updated"' + - 'output_1.diff.before is defined' + - 'output_1.diff.after is defined' + - 'output_2 is changed' + - 'output_2.actions[0] == "Swarm cluster updated"' + - 'output_2.diff.before is defined' + - 'output_2.diff.after is defined' + - 'output_3 is not changed' + - 'output_3.actions[0] == "No modification"' + - 'output_3.diff.before is defined' + - 'output_3.diff.after is defined' + - 'output_4 is not changed' + - 'output_4.actions[0] == "No modification"' + - 'output_4.diff.before is defined' + - 'output_4.diff.after is defined' + - 'output_5 is changed' + - 'output_5.actions[0] == "Swarm cluster updated"' + - 'output_5.diff.before is defined' + - 'output_5.diff.after is defined' + - 'output_6 is changed' + - 'output_6.actions[0] == "Swarm cluster updated"' + - 'output_6.diff.before is defined' + - 'output_6.diff.after is defined' + +#################################################################### +## heartbeat_tick ################################################## +#################################################################### + +- name: heartbeat_tick (check mode) + docker_swarm: + state: present + heartbeat_tick: 2 + check_mode: yes + diff: yes + register: output_1 + +- name: heartbeat_tick + docker_swarm: + state: present + heartbeat_tick: 2 + diff: yes + register: output_2 + +- name: heartbeat_tick (idempotent) + docker_swarm: + state: present + heartbeat_tick: 2 + diff: yes + register: output_3 + +- name: heartbeat_tick (idempotent, check mode) + docker_swarm: + state: present + heartbeat_tick: 2 + check_mode: yes + diff: yes + register: output_4 + +- name: heartbeat_tick (change, check mode) + docker_swarm: + state: present + heartbeat_tick: 3 + check_mode: yes + diff: yes + register: output_5 + +- name: heartbeat_tick (change) + docker_swarm: + state: present + heartbeat_tick: 3 + diff: yes + register: output_6 + +- name: assert changed when remove a swarm cluster + assert: + that: + - 'output_1 is changed' + - 'output_1.actions[0] == "Swarm cluster updated"' + - 'output_1.diff.before is defined' + - 'output_1.diff.after is defined' + - 'output_2 is changed' + - 'output_2.actions[0] == "Swarm cluster updated"' + - 'output_2.diff.before is defined' + - 'output_2.diff.after is defined' + - 'output_3 is not changed' + - 'output_3.actions[0] == "No modification"' + - 'output_3.diff.before is defined' + - 'output_3.diff.after is defined' + - 'output_4 is not changed' + - 'output_4.actions[0] == "No modification"' + - 'output_4.diff.before is defined' + - 'output_4.diff.after is defined' + - 'output_5 is changed' + - 'output_5.actions[0] == "Swarm cluster updated"' + - 'output_5.diff.before is defined' + - 'output_5.diff.after is defined' + - 'output_6 is changed' + - 'output_6.actions[0] == "Swarm cluster updated"' + - 'output_6.diff.before is defined' + - 'output_6.diff.after is defined' + +#################################################################### +## keep_old_snapshots ############################################## +#################################################################### +- name: keep_old_snapshots (check mode) + docker_swarm: + state: present + keep_old_snapshots: 1 + check_mode: yes + diff: yes + register: output_1 + +- name: keep_old_snapshots + docker_swarm: + state: present + keep_old_snapshots: 1 + diff: yes + register: output_2 + +- name: keep_old_snapshots (idempotent) + docker_swarm: + state: present + keep_old_snapshots: 1 + diff: yes + register: output_3 + +- name: keep_old_snapshots (idempotent, check mode) + docker_swarm: + state: present + keep_old_snapshots: 1 + check_mode: yes + diff: yes + register: output_4 + +- name: keep_old_snapshots (change, check mode) + docker_swarm: + state: present + keep_old_snapshots: 2 + check_mode: yes + diff: yes + register: output_5 + +- name: keep_old_snapshots (change) + docker_swarm: + state: present + keep_old_snapshots: 2 + diff: yes + register: output_6 + +- name: assert changed when remove a swarm cluster + assert: + that: + - 'output_1 is changed' + - 'output_1.actions[0] == "Swarm cluster updated"' + - 'output_1.diff.before is defined' + - 'output_1.diff.after is defined' + - 'output_2 is changed' + - 'output_2.actions[0] == "Swarm cluster updated"' + - 'output_2.diff.before is defined' + - 'output_2.diff.after is defined' + - 'output_3 is not changed' + - 'output_3.actions[0] == "No modification"' + - 'output_3.diff.before is defined' + - 'output_3.diff.after is defined' + - 'output_4 is not changed' + - 'output_4.actions[0] == "No modification"' + - 'output_4.diff.before is defined' + - 'output_4.diff.after is defined' + - 'output_5 is changed' + - 'output_5.actions[0] == "Swarm cluster updated"' + - 'output_5.diff.before is defined' + - 'output_5.diff.after is defined' + - 'output_6 is changed' + - 'output_6.actions[0] == "Swarm cluster updated"' + - 'output_6.diff.before is defined' + - 'output_6.diff.after is defined' + +#################################################################### +## labels ########################################################## +#################################################################### +- name: labels (check mode) + docker_swarm: + state: present + labels: + a: v1 + b: v2 + check_mode: yes + diff: yes + register: output_1 + +- name: labels + docker_swarm: + state: present + labels: + a: v1 + b: v2 + diff: yes + register: output_2 + +- name: labels (idempotent) + docker_swarm: + state: present + labels: + a: v1 + b: v2 + diff: yes + register: output_3 + +- name: labels (idempotent, check mode) + docker_swarm: + state: present + labels: + a: v1 + b: v2 + check_mode: yes + diff: yes + register: output_4 + +- name: labels (change, check mode) + docker_swarm: + state: present + labels: + a: v1 + c: v3 + check_mode: yes + diff: yes + register: output_5 + +- name: labels (change) + docker_swarm: + state: present + labels: + a: v1 + c: v3 + diff: yes + register: output_6 + +- name: assert changed when remove a swarm cluster + assert: + that: + - 'output_1 is changed' + - 'output_1.actions[0] == "Swarm cluster updated"' + - 'output_1.diff.before is defined' + - 'output_1.diff.after is defined' + - 'output_2 is changed' + - 'output_2.actions[0] == "Swarm cluster updated"' + - 'output_2.diff.before is defined' + - 'output_2.diff.after is defined' + - 'output_3 is not changed' + - 'output_3.actions[0] == "No modification"' + - 'output_3.diff.before is defined' + - 'output_3.diff.after is defined' + - 'output_4 is not changed' + - 'output_4.actions[0] == "No modification"' + - 'output_4.diff.before is defined' + - 'output_4.diff.after is defined' + - 'output_5 is changed' + - 'output_5.actions[0] == "Swarm cluster updated"' + - 'output_5.diff.before is defined' + - 'output_5.diff.after is defined' + - 'output_6 is changed' + - 'output_6.actions[0] == "Swarm cluster updated"' + - 'output_6.diff.before is defined' + - 'output_6.diff.after is defined' + +#################################################################### +## log_entries_for_slow_followers ################################## +#################################################################### +- name: log_entries_for_slow_followers (check mode) + docker_swarm: + state: present + log_entries_for_slow_followers: 42 + check_mode: yes + diff: yes + register: output_1 + +- name: log_entries_for_slow_followers + docker_swarm: + state: present + log_entries_for_slow_followers: 42 + diff: yes + register: output_2 + +- name: log_entries_for_slow_followers (idempotent) + docker_swarm: + state: present + log_entries_for_slow_followers: 42 + diff: yes + register: output_3 + +- name: log_entries_for_slow_followers (idempotent, check mode) + docker_swarm: + state: present + log_entries_for_slow_followers: 42 + check_mode: yes + diff: yes + register: output_4 + +- name: log_entries_for_slow_followers (change, check mode) + docker_swarm: + state: present + log_entries_for_slow_followers: 23 + check_mode: yes + diff: yes + register: output_5 + +- name: log_entries_for_slow_followers (change) + docker_swarm: + state: present + log_entries_for_slow_followers: 23 + diff: yes + register: output_6 + +- name: assert changed when remove a swarm cluster + assert: + that: + - 'output_1 is changed' + - 'output_1.actions[0] == "Swarm cluster updated"' + - 'output_1.diff.before is defined' + - 'output_1.diff.after is defined' + - 'output_2 is changed' + - 'output_2.actions[0] == "Swarm cluster updated"' + - 'output_2.diff.before is defined' + - 'output_2.diff.after is defined' + - 'output_3 is not changed' + - 'output_3.actions[0] == "No modification"' + - 'output_3.diff.before is defined' + - 'output_3.diff.after is defined' + - 'output_4 is not changed' + - 'output_4.actions[0] == "No modification"' + - 'output_4.diff.before is defined' + - 'output_4.diff.after is defined' + - 'output_5 is changed' + - 'output_5.actions[0] == "Swarm cluster updated"' + - 'output_5.diff.before is defined' + - 'output_5.diff.after is defined' + - 'output_6 is changed' + - 'output_6.actions[0] == "Swarm cluster updated"' + - 'output_6.diff.before is defined' + - 'output_6.diff.after is defined' + +#################################################################### +## name ############################################################ +#################################################################### +- name: name (idempotent, check mode) + docker_swarm: + state: present + name: default + check_mode: yes + diff: yes + register: output_1 + +- name: name (idempotent) + docker_swarm: + state: present + name: default + diff: yes + register: output_2 + +# The name 'default' is hardcoded in docker swarm. Trying to change +# it causes a failure. This might change in the future, so we also +# accept a change for this test. +- name: name (change, should fail) + docker_swarm: + state: present + name: foobar + diff: yes + register: output_3 + ignore_errors: yes + +- name: assert changed when remove a swarm cluster + assert: + that: + - 'output_1 is not changed' + - 'output_1.actions[0] == "No modification"' + - 'output_1.diff.before is defined' + - 'output_1.diff.after is defined' + - 'output_2 is not changed' + - 'output_2.actions[0] == "No modification"' + - 'output_2.diff.before is defined' + - 'output_2.diff.after is defined' + - 'output_3 is failed or output_3 is changed' + +#################################################################### +## node_cert_expiry ################################################ +#################################################################### +- name: node_cert_expiry (check mode) + docker_swarm: + state: present + node_cert_expiry: 7896000000000000 + check_mode: yes + diff: yes + register: output_1 + +- name: node_cert_expiry + docker_swarm: + state: present + node_cert_expiry: 7896000000000000 + diff: yes + register: output_2 + +- name: node_cert_expiry (idempotent) + docker_swarm: + state: present + node_cert_expiry: 7896000000000000 + diff: yes + register: output_3 + +- name: node_cert_expiry (idempotent, check mode) + docker_swarm: + state: present + node_cert_expiry: 7896000000000000 + check_mode: yes + diff: yes + register: output_4 + +- name: node_cert_expiry (change, check mode) + docker_swarm: + state: present + node_cert_expiry: 8766000000000000 + check_mode: yes + diff: yes + register: output_5 + +- name: node_cert_expiry (change) + docker_swarm: + state: present + node_cert_expiry: 8766000000000000 + diff: yes + register: output_6 + +- name: assert changed when remove a swarm cluster + assert: + that: + - 'output_1 is changed' + - 'output_1.actions[0] == "Swarm cluster updated"' + - 'output_1.diff.before is defined' + - 'output_1.diff.after is defined' + - 'output_2 is changed' + - 'output_2.actions[0] == "Swarm cluster updated"' + - 'output_2.diff.before is defined' + - 'output_2.diff.after is defined' + - 'output_3 is not changed' + - 'output_3.actions[0] == "No modification"' + - 'output_3.diff.before is defined' + - 'output_3.diff.after is defined' + - 'output_4 is not changed' + - 'output_4.actions[0] == "No modification"' + - 'output_4.diff.before is defined' + - 'output_4.diff.after is defined' + - 'output_5 is changed' + - 'output_5.actions[0] == "Swarm cluster updated"' + - 'output_5.diff.before is defined' + - 'output_5.diff.after is defined' + - 'output_6 is changed' + - 'output_6.actions[0] == "Swarm cluster updated"' + - 'output_6.diff.before is defined' + - 'output_6.diff.after is defined' + +#################################################################### +## rotate_manager_token ############################################ +#################################################################### +- name: rotate_manager_token (true, check mode) + docker_swarm: + state: present + rotate_manager_token: yes + check_mode: yes + diff: yes + register: output_1 + +- name: rotate_manager_token (true) + docker_swarm: + state: present + rotate_manager_token: yes + diff: yes + register: output_2 + +- name: rotate_manager_token (false, idempotent) + docker_swarm: + state: present + rotate_manager_token: no + diff: yes + register: output_3 + +- name: rotate_manager_token (false, check mode) + docker_swarm: + state: present + rotate_manager_token: no + check_mode: yes + diff: yes + register: output_4 + +- name: assert changed when remove a swarm cluster + assert: + that: + - 'output_1 is changed' + - 'output_1.actions[0] == "Swarm cluster updated"' + - 'output_1.diff.before is defined' + - 'output_1.diff.after is defined' + - 'output_2 is changed' + - 'output_2.actions[0] == "Swarm cluster updated"' + - 'output_2.diff.before is defined' + - 'output_2.diff.after is defined' + - 'output_3 is not changed' + - 'output_3.actions[0] == "No modification"' + - 'output_3.diff.before is defined' + - 'output_3.diff.after is defined' + - 'output_4 is not changed' + - 'output_4.actions[0] == "No modification"' + - 'output_4.diff.before is defined' + - 'output_4.diff.after is defined' + +#################################################################### +## rotate_worker_token ############################################# +#################################################################### +- name: rotate_worker_token (true, check mode) + docker_swarm: + state: present + rotate_worker_token: yes + check_mode: yes + diff: yes + register: output_1 + +- name: rotate_worker_token (true) + docker_swarm: + state: present + rotate_worker_token: yes + diff: yes + register: output_2 + +- name: rotate_worker_token (false, idempotent) + docker_swarm: + state: present + rotate_worker_token: no + diff: yes + register: output_3 + +- name: rotate_worker_token (false, check mode) + docker_swarm: + state: present + rotate_worker_token: no + check_mode: yes + diff: yes + register: output_4 + +- name: assert changed when remove a swarm cluster + assert: + that: + - 'output_1 is changed' + - 'output_1.actions[0] == "Swarm cluster updated"' + - 'output_1.diff.before is defined' + - 'output_1.diff.after is defined' + - 'output_2 is changed' + - 'output_2.actions[0] == "Swarm cluster updated"' + - 'output_2.diff.before is defined' + - 'output_2.diff.after is defined' + - 'output_3 is not changed' + - 'output_3.actions[0] == "No modification"' + - 'output_3.diff.before is defined' + - 'output_3.diff.after is defined' + - 'output_4 is not changed' + - 'output_4.actions[0] == "No modification"' + - 'output_4.diff.before is defined' + - 'output_4.diff.after is defined' + +#################################################################### +## snapshot_interval ############################################### +#################################################################### +- name: snapshot_interval (check mode) + docker_swarm: + state: present + snapshot_interval: 12345 + check_mode: yes + diff: yes + register: output_1 + +- name: snapshot_interval + docker_swarm: + state: present + snapshot_interval: 12345 + diff: yes + register: output_2 + +- name: snapshot_interval (idempotent) + docker_swarm: + state: present + snapshot_interval: 12345 + diff: yes + register: output_3 + +- name: snapshot_interval (idempotent, check mode) + docker_swarm: + state: present + snapshot_interval: 12345 + check_mode: yes + diff: yes + register: output_4 + +- name: snapshot_interval (change, check mode) + docker_swarm: + state: present + snapshot_interval: 54321 + check_mode: yes + diff: yes + register: output_5 + +- name: snapshot_interval (change) + docker_swarm: + state: present + snapshot_interval: 54321 + diff: yes + register: output_6 + +- name: assert changed when remove a swarm cluster + assert: + that: + - 'output_1 is changed' + - 'output_1.actions[0] == "Swarm cluster updated"' + - 'output_1.diff.before is defined' + - 'output_1.diff.after is defined' + - 'output_2 is changed' + - 'output_2.actions[0] == "Swarm cluster updated"' + - 'output_2.diff.before is defined' + - 'output_2.diff.after is defined' + - 'output_3 is not changed' + - 'output_3.actions[0] == "No modification"' + - 'output_3.diff.before is defined' + - 'output_3.diff.after is defined' + - 'output_4 is not changed' + - 'output_4.actions[0] == "No modification"' + - 'output_4.diff.before is defined' + - 'output_4.diff.after is defined' + - 'output_5 is changed' + - 'output_5.actions[0] == "Swarm cluster updated"' + - 'output_5.diff.before is defined' + - 'output_5.diff.after is defined' + - 'output_6 is changed' + - 'output_6.actions[0] == "Swarm cluster updated"' + - 'output_6.diff.before is defined' + - 'output_6.diff.after is defined' + +#################################################################### +## task_history_retention_limit #################################### +#################################################################### +- name: task_history_retention_limit (check mode) + docker_swarm: + state: present + task_history_retention_limit: 23 + check_mode: yes + diff: yes + register: output_1 + +- name: task_history_retention_limit + docker_swarm: + state: present + task_history_retention_limit: 23 + diff: yes + register: output_2 + +- name: task_history_retention_limit (idempotent) + docker_swarm: + state: present + task_history_retention_limit: 23 + diff: yes + register: output_3 + +- name: task_history_retention_limit (idempotent, check mode) + docker_swarm: + state: present + task_history_retention_limit: 23 + check_mode: yes + diff: yes + register: output_4 + +- name: task_history_retention_limit (change, check mode) + docker_swarm: + state: present + task_history_retention_limit: 7 + check_mode: yes + diff: yes + register: output_5 + +- name: task_history_retention_limit (change) + docker_swarm: + state: present + task_history_retention_limit: 7 + diff: yes + register: output_6 + +- name: assert changed when remove a swarm cluster + assert: + that: + - 'output_1 is changed' + - 'output_1.actions[0] == "Swarm cluster updated"' + - 'output_1.diff.before is defined' + - 'output_1.diff.after is defined' + - 'output_2 is changed' + - 'output_2.actions[0] == "Swarm cluster updated"' + - 'output_2.diff.before is defined' + - 'output_2.diff.after is defined' + - 'output_3 is not changed' + - 'output_3.actions[0] == "No modification"' + - 'output_3.diff.before is defined' + - 'output_3.diff.after is defined' + - 'output_4 is not changed' + - 'output_4.actions[0] == "No modification"' + - 'output_4.diff.before is defined' + - 'output_4.diff.after is defined' + - 'output_5 is changed' + - 'output_5.actions[0] == "Swarm cluster updated"' + - 'output_5.diff.before is defined' + - 'output_5.diff.after is defined' + - 'output_6 is changed' + - 'output_6.actions[0] == "Swarm cluster updated"' + - 'output_6.diff.before is defined' + - 'output_6.diff.after is defined'