Last active
September 28, 2018 18:26
-
-
Save designrubenz/376eb644c7bf41fcb1a38ac275c7b05d to your computer and use it in GitHub Desktop.
ansible
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
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