Copy Module:
Yum module:
Setup Module:
Demo of above modules:
ansible-doc -l --> To list all modules.
Select the module you want and see the full description of it.
ansible-doc yum
To install apache:
ansible webservers -i inventory -m yum -a "name=httpd state=present" --sudo
It will check already installed or not and skip if already there.It can be seen using the changed part in the output.
ansible webservers -i inventory -m yum -a "name=httpd enabled=yes state=started" --sudo
This will start also the service.
ansible dbservers -i inventory -m yum -a "name=mysql-server state=present" --sudo
ansible dbservers -i inventory -m yum -a "name=mysql-server state=started" --sudo
To stop firewall:
ansible webservers:dbservers -i inventory -m service -a "name=iptables state=stopped" --sudo
ansible web1 -i inventory -m setup
Will give details/facts about the system(as key/value pairs in json structure), we can use these values as the variables.
ansible web1 -i inventory -m setup -a "filter=ansible_eth*"
ansible web1 -i inventory -m setup -a "filter=ansible_mounts"
ansible all -i inventory -m setup --tree ./setup --> to dump all data in the setup folder.
- Copies a file from local-box to remote system
- Has "backup" capability
- Can do validation remotely
- Opposite to Copy module, Pulls a file from remote host to local system
- Can use md5 check-sums to validate
- Manages installed applications on Debian based systems
- Can install, update, or delete packages
- Can update entire system
Yum module:
- Manages installed applications on Redhat-based systems
- Can install, update, or delete packages
- Can update entire system
- Can stop, start or restart services
- Can enable services to start on boot
Setup Module:
- Gather facts on remote systems
- Used in Playbooks
Demo of above modules:
- Install web server (Yum module)
- Start Web server (service module)
- Install DB Server (Yum module)
- Start DB Server (Service module)
- Stop Firewalls (Service module)
ansible-doc -l --> To list all modules.
Select the module you want and see the full description of it.
ansible-doc yum
To install apache:
ansible webservers -i inventory -m yum -a "name=httpd state=present" --sudo
It will check already installed or not and skip if already there.It can be seen using the changed part in the output.
ansible webservers -i inventory -m yum -a "name=httpd enabled=yes state=started" --sudo
This will start also the service.
ansible dbservers -i inventory -m yum -a "name=mysql-server state=present" --sudo
ansible dbservers -i inventory -m yum -a "name=mysql-server state=started" --sudo
To stop firewall:
ansible webservers:dbservers -i inventory -m service -a "name=iptables state=stopped" --sudo
ansible web1 -i inventory -m setup
Will give details/facts about the system(as key/value pairs in json structure), we can use these values as the variables.
ansible web1 -i inventory -m setup -a "filter=ansible_eth*"
ansible web1 -i inventory -m setup -a "filter=ansible_mounts"
ansible all -i inventory -m setup --tree ./setup --> to dump all data in the setup folder.
No comments:
Post a Comment