Created
January 15, 2023 03:43
-
-
Save castironclay/186375232806b1e7fc561d4fd2411764 to your computer and use it in GitHub Desktop.
ansibe hosts using master control sockets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Add frontend host | |
hosts: localhost | |
tasks: | |
- name: Create master control socket | |
shell: | |
cmd: "sshpass -p '{{ backend_password }}' ssh -fN -M -S /tmp/{{ backend_ip }} {{ backend_username }}@{{ backend_ip }}" | |
executable: /bin/bash | |
- name: Add frontend | |
add_host: | |
name: frontend | |
ansible_host: "{{ frontend_ip }}" | |
groups: "frontend_setup" | |
ansible_user: "{{ frontend_username }}" | |
ansible_password: "{{ frontend_password }}" | |
ansible_become_password: "{{ frontend_password }}" | |
ansible_python_interpreter: /usr/bin/python3 | |
ansible_ssh_common_args: "-o StrictHostKeyChecking=no -o ProxyCommand='ssh -S /tmp/{{ backend_ip }} -W %h:%p -q {{ backend_username }}@{{ backend_ip }}'" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment