Thursday 26 May 2016

Ansible installation_and_its_setup

How to install ansible on our machines:
-----------------------------------------

1) Yum install epel-release
2) yum install ansible

To write commands in Ansible"

ansible 127.0.0.1 -m yum -a "name=software state=present" 

Then the software will be installed on your machine.

eg:
installing postgresql using ansible

ansible 127.0.0.1 -m yum -a "name=postgresql state=present"


---
- hosts: [target hosts]
  remote_user: [yourname]
  tasks:
    - [task 1]
    - [task 2]

Sample service check playbook


---
- hosts: [marketingservers]
  remote_user: webadmin
  tasks:
    - name: Ensure the Apache daemon has started
      service: name=httpd state=started
      become: yes
      become_method: sudo


Playbook task
tasks:
    - name: Ensure the Apache daemon has started
      service: name=httpd state=started
      become: yes

      become_method: sudo



No comments:

Post a Comment