--- # file: roles/nginx_cluster/tasks/setup-server.yml - name: "{{ hostvars[item]['ansible_hostname'] }} - Setup block for ssh connection between members" blockinfile: path: /etc/ssh/sshd_config.d/60-nginx-cluster.conf marker: "# {mark} ANSIBLE MANAGED BLOCK {{ hostvars[item]['ansible_hostname'] }}" create: true block: | ## Allow root login from cluster member {{ hostvars[item]['ansible_host'] }} Match Address {{ hostvars[item]['ansible_host'] }} PermitRootLogin yes notify: Restart SSH when: nginx_cluster_user == "root" - name: "{{ hostvars[item]['ansible_hostname'] }} - Setup authorized key for the user" authorized_key: user: "{{ nginx_cluster_user }}" state: present key: "{{ hostvars[item]['nginx_cluster_public_key'] }}"