2019-07-25 18:49:30 +02:00
|
|
|
- debug:
|
|
|
|
msg: Running tests/options-ca.yml
|
|
|
|
|
|
|
|
- name: options-ca
|
|
|
|
when: pyopenssl_version.stdout is version('0.15', '>=') or
|
|
|
|
cryptography_version.stdout is version('1.6', '>=')
|
|
|
|
block:
|
2019-02-27 20:54:32 +01:00
|
|
|
- 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
|
2019-03-05 19:50:28 +01:00
|
|
|
signing_ca_cert: "{{ lookup('file', output_dir ~ '/ansible_key1.pem') }}"
|
|
|
|
signing_ca_key: "{{ lookup('file', output_dir ~ '/ansible_key1.key') }}"
|
2019-02-27 20:54:32 +01:00
|
|
|
timeout: 120
|
|
|
|
check_mode: yes
|
|
|
|
diff: yes
|
|
|
|
register: output_1
|
2019-03-04 12:10:09 +01:00
|
|
|
ignore_errors: yes
|
2019-02-27 20:54:32 +01:00
|
|
|
|
|
|
|
- name: signing_ca_cert and signing_ca_key
|
|
|
|
docker_swarm:
|
|
|
|
advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
|
|
|
|
state: present
|
2019-03-05 19:50:28 +01:00
|
|
|
signing_ca_cert: "{{ lookup('file', output_dir ~ '/ansible_key1.pem') }}"
|
|
|
|
signing_ca_key: "{{ lookup('file', output_dir ~ '/ansible_key1.key') }}"
|
2019-02-27 20:54:32 +01:00
|
|
|
timeout: 120
|
|
|
|
diff: yes
|
|
|
|
register: output_2
|
2019-03-04 12:10:09 +01:00
|
|
|
ignore_errors: yes
|
2019-02-27 20:54:32 +01:00
|
|
|
|
|
|
|
- name: Private key
|
2019-03-05 19:50:28 +01:00
|
|
|
debug: msg="{{ lookup('file', output_dir ~ '/ansible_key1.key') }}"
|
2019-02-27 20:54:32 +01:00
|
|
|
- name: Cert
|
2019-03-05 19:50:28 +01:00
|
|
|
debug: msg="{{ lookup('file', output_dir ~ '/ansible_key1.pem') }}"
|
2019-03-21 09:37:18 +01:00
|
|
|
- docker_swarm_info:
|
2019-02-27 20:54:32 +01:00
|
|
|
register: output
|
2019-03-04 12:10:09 +01:00
|
|
|
ignore_errors: yes
|
2019-02-27 20:54:32 +01:00
|
|
|
- debug: var=output
|
|
|
|
|
|
|
|
# Idempotence for CA cert and key don't work yet! FIXME
|
|
|
|
|
|
|
|
#- name: signing_ca_cert and signing_ca_key (idempotent)
|
|
|
|
# docker_swarm:
|
|
|
|
# state: present
|
2019-03-05 19:50:28 +01:00
|
|
|
# signing_ca_cert: "{{ lookup('file', output_dir ~ '/ansible_key1.pem') }}"
|
|
|
|
# signing_ca_key: "{{ lookup('file', output_dir ~ '/ansible_key1.key') }}"
|
2019-02-27 20:54:32 +01:00
|
|
|
# timeout: 120
|
|
|
|
# diff: yes
|
|
|
|
# register: output_3
|
2019-03-04 12:10:09 +01:00
|
|
|
# ignore_errors: yes
|
2019-02-27 20:54:32 +01:00
|
|
|
|
|
|
|
#- name: signing_ca_cert and signing_ca_key (idempotent, check mode)
|
|
|
|
# docker_swarm:
|
|
|
|
# state: present
|
2019-03-05 19:50:28 +01:00
|
|
|
# signing_ca_cert: "{{ lookup('file', output_dir ~ '/ansible_key1.pem') }}"
|
|
|
|
# signing_ca_key: "{{ lookup('file', output_dir ~ '/ansible_key1.key') }}"
|
2019-02-27 20:54:32 +01:00
|
|
|
# timeout: 120
|
|
|
|
# check_mode: yes
|
|
|
|
# diff: yes
|
|
|
|
# register: output_4
|
2019-03-04 12:10:09 +01:00
|
|
|
# ignore_errors: yes
|
2019-02-27 20:54:32 +01:00
|
|
|
|
|
|
|
- name: signing_ca_cert and signing_ca_key (change, check mode)
|
|
|
|
docker_swarm:
|
|
|
|
state: present
|
2019-03-05 19:50:28 +01:00
|
|
|
signing_ca_cert: "{{ lookup('file', output_dir ~ '/ansible_key2.pem') }}"
|
|
|
|
signing_ca_key: "{{ lookup('file', output_dir ~ '/ansible_key2.key') }}"
|
2019-02-27 20:54:32 +01:00
|
|
|
timeout: 120
|
|
|
|
check_mode: yes
|
|
|
|
diff: yes
|
|
|
|
register: output_5
|
2019-03-04 12:10:09 +01:00
|
|
|
ignore_errors: yes
|
2019-02-27 20:54:32 +01:00
|
|
|
|
|
|
|
- name: signing_ca_cert and signing_ca_key (change)
|
|
|
|
docker_swarm:
|
|
|
|
state: present
|
2019-03-05 19:50:28 +01:00
|
|
|
signing_ca_cert: "{{ lookup('file', output_dir ~ '/ansible_key2.pem') }}"
|
|
|
|
signing_ca_key: "{{ lookup('file', output_dir ~ '/ansible_key2.key') }}"
|
2019-02-27 20:54:32 +01:00
|
|
|
timeout: 120
|
|
|
|
diff: yes
|
|
|
|
register: output_6
|
2019-03-04 12:10:09 +01:00
|
|
|
ignore_errors: yes
|
2019-02-27 20:54:32 +01:00
|
|
|
|
|
|
|
- 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'
|
2019-03-04 12:10:09 +01:00
|
|
|
when: docker_py_version is version('2.6.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- output_1 is failed
|
2019-06-23 21:52:24 +02:00
|
|
|
- "('version is ' ~ docker_py_version ~ ' ') in output_1.msg"
|
|
|
|
- "'Minimum version required is 2.6.0 ' in output_1.msg"
|
2019-03-04 12:10:09 +01:00
|
|
|
when: docker_py_version is version('2.6.0', '<')
|
2019-02-27 20:54:32 +01:00
|
|
|
|
2019-07-25 18:49:30 +02:00
|
|
|
- include_tasks: cleanup.yml
|