diff --git a/roles/mongodb_auth/tasks/main.yml b/roles/mongodb_auth/tasks/main.yml index 3795141..64633a2 100644 --- a/roles/mongodb_auth/tasks/main.yml +++ b/roles/mongodb_auth/tasks/main.yml @@ -19,12 +19,12 @@ when: mongodb_replication | bool - name: Check if key exists on the first node + ansible.builtin.stat: + path: "{{ mongo_auth_keyfile_destination }}" when: - inventory_hostname == groups['mongodb'][0] - mongodb_replication | bool run_once: true - ansible.builtin.stat: - path: "{{ mongo_auth_keyfile_destination }}" register: keyfile_stat - name: Generate key (if missing) and copy to all nodes