Skip to content

Instantly share code, notes, and snippets.

@chrisblossom
chrisblossom / gist:8690833
Last active February 23, 2016 07:40
Dynamically set ansible ansible_ssh_port and ansible_ssh_user
---
# 1) Be sure to set the following variables for all hosts:
# vars:
# oldsshport: 22
# sshport: 555
# 2) Might fail without setting remote_tmp = /tmp/ansible/$USER in your ansible.cfg. Includes a fix for this setting below.
# 3) Once host is setup most of the checks are skipped and works very quickly.
# 4) Be sure to set non-standard shells in a different playbook later. Stick with /bin/bash until you can run apt install.
# 5) Assumes root user has sshkey setup already. Not sure how to utilize the --ask-pass option. For now, use ssh-copy-id prior to running playbook on new host for root user (if needed).