Prefer capath over cafile

pull/83197/head
Matt Clay 1 month ago
parent 6bdd921368
commit b2f0ec8b2e

@ -10,3 +10,9 @@
- name: Unregister cacert - name: Unregister cacert
command: openssl rehash {{ capath.stdout }} command: openssl rehash {{ capath.stdout }}
- name: Remove cacert from cafile
blockinfile:
path: "{{ capaths.cafile }}"
block: "{{ cacert_pem.content }}"
state: absent

@ -45,20 +45,29 @@
return_content: true return_content: true
register: cacert_pem register: cacert_pem
- name: Locate capath - name: Get cafile and capath
command: '{{ ansible_python_interpreter }} -c "import ssl; print(ssl.get_default_verify_paths().capath)"' command: '{{ ansible_python_interpreter }} -c "import ssl, json; paths = ssl.get_default_verify_paths(); print(json.dumps(dict(cafile=paths.cafile, capath=paths.capath)));"'
register: capath register: capaths
- name: Assert capath is set - name: Parse cafile and capath
assert: set_fact:
that: capath.stdout capaths: "{{ capaths.stdout | from_json }}"
- name: Add cacert to capath - name: Add cacert to capath
copy: copy:
content: "{{ cacert_pem.content }}" content: "{{ cacert_pem.content }}"
dest: "{{ capath.stdout }}/ansible-http-test.pem" dest: "{{ capaths.capath }}/ansible-http-test.pem"
notify: Remove cacert from capath notify: Remove cacert from capath
when: capaths.capath is not none
- name: Register cacert - name: Register cacert
command: openssl rehash {{ capath.stdout }} command: openssl rehash {{ capaths.capath }}
notify: Unregister cacert notify: Unregister cacert
when: capaths.capath is not none
- name: Add cacert to cafile
blockinfile:
path: "{{ capaths.cafile }}"
block: "{{ cacert_pem.content }}"
notify: Remove cacert from cafile
when: capaths.capath is none

Loading…
Cancel
Save