How to install ansible on our machines:
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
-----------------------------------------
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