Skip to content

Instantly share code, notes, and snippets.

@designrubenz
Last active September 28, 2018 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save designrubenz/376eb644c7bf41fcb1a38ac275c7b05d to your computer and use it in GitHub Desktop.
Save designrubenz/376eb644c7bf41fcb1a38ac275c7b05d to your computer and use it in GitHub Desktop.
ansible
Note: By default Ansible will use the same username as your current machine’s username.
Ansible ad hoc command, python not installed on host
ansible -i realhosts host1 -m raw -a "uname -r" -u root
realhosts file:
[web]
host1 ansible_ssh_host=12.123.456.789
Ping a host (mybox) defined in your hosts file:
ansible -i hosts mybox -m ping --connection=local
Pass variable to command: -e
ansible-playbook -i hosts task.yml -e file_state=touch
2 ways of accessing localhost:
1. through ssh (slower)
2. directly (connection: local)!
---
- hosts: localhost
tasks:
- name: create a file via ssh connection
file:
dest: /tmp/ssh-created
state: touch
- hosts: localhost
connection: local
tasks:
- name: create a file via direct local connection
file:
dest: /tmp/direct-created
state: touch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment