Professional Documents
Culture Documents
DevOps 05182017 Ansible Install HTTPD Variable Files Handlers
DevOps 05182017 Ansible Install HTTPD Variable Files Handlers
DevOps 05182017 Ansible Install HTTPD Variable Files Handlers
-This is Push method and agent else and runs on "Python" language
-We use SSH connection (How to create SSH connection is given below) for connection other
nodes(Server's)
-We can run adhoc job @ CLI promt
-Ansible modules are called as "playbooks"
-Installation of Ansible
-First we need to get extra package repository "epel" (Extra Package Enterprise Linux)
[root@server1 ~]# yum install epel - release
-Now we should be give permission to the "user1" where we are going to run Ansible playbook
[root@server1 ~]# visudo
-Now update the server name along with ip in the below path
[root@server1 ~]# cd /etc
[root@server1 etc]# vi hosts
-Now update the "ansible" host inventory files in the path "/etc/ansible/"
[root@server1 ~]# cd /etc/ansible/
[root@server1 ansible]# ls
ansible.cfg hosts index.html roles webserver.yml
-Now rename the exiting "hosts" file to hosts.orig (If required we can use the original file later)
[root@server1 ansible]# cp hosts hosts.orig
[root@server1 ansible]# ls
ansible.cfg hosts hosts.orig index.html roles webserver.yml
-To verify the list of modules available in ansible use the below command
[root@server1 ~]# ansible-doc -l
-To view particular info about module use the below command (Example are bottom)
[root@server1 ~]# ansible-doc yum
-Install "httpd" from command line (Without playbook) from user1/server1 to user1/server2
[user1@server1 ~]$ ansible server2 -m yum -a "name=httpd state=present"
or
-Now verify whether you have access to user1/server2 without passowrd less authnication
[user1@server1 ~]$ ssh user1@server2
-
First ansible playbooks.
-Now we are going to install "httpd" in server2 using ansible playbook called "webserver.yml"
-The below example will illustrate how to setup web server "httpd"
-If the above output is not as desired please verify the below
[root@server1 ~]# service iptables stop
-How to use variables in Ansible
-Create variable.yml file as show below from previous webserver.yml
[user1@server1 ~]$ cp webserver.yml variable.yml
-In the below example we are going to name "httpd1" instead of "httpd"
ignore_errors: yes, this will ignore and execute the next task
more.sh
-How to Example on "ls" command (unix)
-How to execute shell script in Ansible