Professional Documents
Culture Documents
Ansi Tom
Ansi Tom
sudo su -
yum update
ansible --version
useradd ansadmin
passwd ansadmin
visudo
ansadmin ALL=(ALL) NOPASSWD: ALL
cd /etc/ssh/
vi sshd_config
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------
MASTER:
sudo su - ansadmin
ssh-keygen
ssh-copy-d IP(SLAVE)
ssh IP(should not ask for pwd)
sudo vi /etc/ansible/hosts
[web_servers]
IP(SLAVE)
ansible all -m yum -a "name=httpd state=latest" -> does not install http on SLAVE
as it does not have httpd access
ansible -b all -m yum -a "name=httpd state=latest" -> installs httpd in slave (b by
default root user)
ansible -b all -m yum -a "name=httpd state=started" -> starts httpd in slave
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------
JENKINS:
ANSIBLE:
/home/ansadmin/playbooks/ - copyfile.yml
---
- hosts: web-servers ----------------> (this is the one that is defines in
/etc/ansible/hosts and connects to tomcat server)
become: true
tasks:
- name: copy war onto tomcat servers
copy:
src: /home/ansadmin/playbooks/webapp/target/webapp.war
dest: /home/ansadmin/tomcat/