Difference between revisions of "Ansible"

From Bashlinux
Jump to: navigation, search
(Created page with "__NOTOC__ == Setup == === How to install Ansible === * On Ubuntu # apt-get -y install ansible * On Fedora # dnf -y install ansible === How to add nodes to ansible list === ...")
 
(No difference)

Latest revision as of 22:45, 10 July 2015

Setup

How to install Ansible

  • On Ubuntu
# apt-get -y install ansible
  • On Fedora
# dnf -y install ansible

How to add nodes to ansible list

  • Edit the file /etc/ansible/hosts and list all the nodes there
  • Nodes can be grouped under a section named defined on square brackets
[my_group]
host01
host02
  • Groups can also be grouped in another set of groups
[global_group:children]
my_group
another_group

Commands

How to ping the nodes

  • All the nodes
# ansible all -m ping
  • A particular group of nodes
# ansible my_group -m ping

How to execute a command on the nodes

ansible my_group -s -m shell -a 'apt-get -y install package'