Home‎ > ‎Scripting‎ > ‎

Ansible



Adhoc scripts


create a temp hostfile and run a command against all machines in that file
the first line in temp-hostlist is creating a hostgroup called allhosts

vi temp-hostlist
[allhosts]
server1
server2

run uptime against the  "allhosts"  hostgroup in the ./temp-hostlist file
ansible allhosts -i ./temp-hostlist  --ask-pass --ask-sudo-pass -m command -a "uptime"


Limit host with regex to include only servers where the 15th character is a 1
ansible-playbook --limit='~^.{14}1'



Comments