sudo pip install markupsafe
sudo pip install xmltodict
sudo pip install pywinrm
sudo pip install ansible
ansible --version
inventory.yml
------------
---
[web]
192.168.57.3
group_vars/web.yml
-------------------
ansible_user: vagrant
ansible_password: vagrant
ansible_port: 5985
ansible_connection: winrm
ansible_winrm_cert_validation: ignore
ansible web -i inventory.yml -m win_ping
--------------------------------
for ubuntu:
sudo apt-get install ansible
for centos:
sudo yum install epel-release --- enterprise linux softeare repos.
sudo yum install ansible
using python:
sudo yum install gcc
sudo yum install python-setuptools
sudo easy_install pip
sudo yum install python-devel
sudo pip install ansible
inventory file
-----------------
list of ip addresses
ansible all(or)*(or)ipaddress -i inventory -u vagrant -m ping -k -v
-k --> for password prompt
-v --> debug or verbose mode, level 1
-vv --> level 2 debugging
similarly -vvv
if u get ssh error, theen do a ssh connection to that macchine once.
ssh username@ipaddress
command module:
--------
-m command -a "usr/sbin/yum update -y"
defualt is the command module, so we can skip -m
-a "/sbin/reboot"
command module will run an executable inside a python, shell module runs inside the shell directly, so we can use shell variables.
---
inventory file
===============
web1 ansible_ssh_host=ip_address ansible_ssh_user=user ansible_ssh_pass=password
ansible web1 -i inventory -m ping
inventory file
===============
web1 ansible_ssh_host=ip_address ansible_ssh_user=user ansible_ssh_pass=password
db1 ansible_ssh_host=ip_address ansible_ssh_user=user ansible_ssh_pass=password
web2 ansible_ssh_host=ip_address ansible_ssh_user=user ansible_ssh_pass=password
[webservers]--->group
web1
web2
[dbservers]
db1
[datacenter:children] -->children means contains groups instead of names
webservers
dbservers
ansible webservers -i inventory -m ping
ansible datacenter -i inventory -m ping
--
inventory file
===============
web1 ansible_ssh_host=ip_address
db1 ansible_ssh_host=ip_address
[webservers]
web1
[dbservers]
db1
[datacenter:children]
webservers
dbservers
[datacenter:vars]
ansible_ssh_user=vagrant
ansible_ssh_pass=vagrant
sudo pip install xmltodict
sudo pip install pywinrm
sudo pip install ansible
ansible --version
inventory.yml
------------
---
[web]
192.168.57.3
group_vars/web.yml
-------------------
ansible_user: vagrant
ansible_password: vagrant
ansible_port: 5985
ansible_connection: winrm
ansible_winrm_cert_validation: ignore
ansible web -i inventory.yml -m win_ping
--------------------------------
for ubuntu:
sudo apt-get install ansible
for centos:
sudo yum install epel-release --- enterprise linux softeare repos.
sudo yum install ansible
using python:
sudo yum install gcc
sudo yum install python-setuptools
sudo easy_install pip
sudo yum install python-devel
sudo pip install ansible
inventory file
-----------------
list of ip addresses
ansible all(or)*(or)ipaddress -i inventory -u vagrant -m ping -k -v
-k --> for password prompt
-v --> debug or verbose mode, level 1
-vv --> level 2 debugging
similarly -vvv
if u get ssh error, theen do a ssh connection to that macchine once.
ssh username@ipaddress
command module:
--------
-m command -a "usr/sbin/yum update -y"
defualt is the command module, so we can skip -m
-a "/sbin/reboot"
command module will run an executable inside a python, shell module runs inside the shell directly, so we can use shell variables.
---
inventory file
===============
web1 ansible_ssh_host=ip_address ansible_ssh_user=user ansible_ssh_pass=password
ansible web1 -i inventory -m ping
inventory file
===============
web1 ansible_ssh_host=ip_address ansible_ssh_user=user ansible_ssh_pass=password
db1 ansible_ssh_host=ip_address ansible_ssh_user=user ansible_ssh_pass=password
web2 ansible_ssh_host=ip_address ansible_ssh_user=user ansible_ssh_pass=password
[webservers]--->group
web1
web2
[dbservers]
db1
[datacenter:children] -->children means contains groups instead of names
webservers
dbservers
ansible webservers -i inventory -m ping
ansible datacenter -i inventory -m ping
--
inventory file
===============
web1 ansible_ssh_host=ip_address
db1 ansible_ssh_host=ip_address
[webservers]
web1
[dbservers]
db1
[datacenter:children]
webservers
dbservers
[datacenter:vars]
ansible_ssh_user=vagrant
ansible_ssh_pass=vagrant
No comments:
Post a Comment