- name: Test if VAPID private key exists shell: grep -c "^{{ item.name }}_vapid_private_key_base64" "{{ inventory_dir }}/group_vars/all/passwords.yaml" || true register: vapid_private_key_test_grep - name: Test if VAPID public key exists shell: grep -c "^{{ item.name }}_vapid_public_key_base64" "{{ inventory_dir }}/group_vars/all/passwords.yaml" || true register: vapid_public_key_test_grep - name: Create VAPID keys docker_container: name: vapid image: "{{ docker_registry }}/pwgen" cleanup: true detach: false container_default_behavior: no_defaults command: "/vapid" register: vapid_container_output when: vapid_private_key_test_grep.stdout == '0' or vapid_public_key_test_grep.stdout == '0' - name: Set VAPID keys fact set_fact: vapid_keys: "{{ vapid_container_output.ansible_facts.docker_container.Output | from_yaml }}" when: vapid_private_key_test_grep.stdout == '0' or vapid_public_key_test_grep.stdout == '0' - name: Show VAPID private key debug: msg: "vapid private key: {{ vapid_keys['vapidPrivateKey'] }}" verbosity: 2 when: vapid_private_key_test_grep.stdout == '0' - name: Show VAPID public key debug: msg: "vapid public key: {{ vapid_keys['vapidPublicKey'] }}" verbosity: 2 when: vapid_public_key_test_grep.stdout == '0' - name: Write VAPID private key lineinfile: path: "{{ inventory_dir }}/group_vars/all/passwords.yaml" line: "{{ item.name }}_vapid_private_key_base64: \"{{ vapid_keys['vapidPrivateKey'] | b64encode }}\"" when: vapid_private_key_test_grep.stdout == '0' - name: Write VAPID public key lineinfile: path: "{{ inventory_dir }}/group_vars/all/passwords.yaml" line: "{{ item.name }}_vapid_public_key_base64: \"{{ vapid_keys['vapidPublicKey'] | b64encode }}\"" when: vapid_public_key_test_grep.stdout == '0'