Ansible is a computer software or software that is open-source that can help a devops or system administrators to perform automation in the server. Ansible can help doing the installation, deployment, even updating multiple servers at once simultaneously.
Ansible can also connect to LDAP and Kerberos server of some sort then set everything in it. So what ansible work? Ansible generally work like other tools, such as Chef, Puppet, only Ansible does not require an agent. Ansible only worked enough with the SSH connection.
Ansible is working in a remote SSH connection to the client that you want to deploy the automation or done. Ansible also requires data inventory or data destination server. More use to the next level, ansible can also play a role as playbook and roles. The configuration is written in YAML markup format and environment variable can be written in JSON format. Why does YAML YAML markup, probably because it is very easy to read by humans. So that may be an ansible documentation of its own later.
Here is how to install the Ansible, the first step to install software properties:
root @: ~ mulawarman apt-gel software to install-properties-common-y
Add repository specifically for Ansible
root @: ~ mulawarman apt-add-ppa repository: ansible/ansible
Do update
root @: ~ # mulawarman apt-get update
Then install the Ansible
root @: ~ # mulawarman apt-get install-y ansible
Then edit the hosts file located in the/etc/ansible/hosts directory to create a list of host or server diotomasi. Here the author makes a list of the hosts that you want to automate creating the parameter host by the name of powertech in final line, then add the IP Address of the host you want to add under the name of the parameter.
##
# # dbo1.intranet.mydomain.net
# # dbo2.intranet.mydomain.net
# # 10.25.1.56
# # 10.25.1.57
# Here's another example of the host ranges, this time there are no
# leading 0s:
# db-[99:101]-node.example.com
[powertech]
103,195 5.55.
35,198,213,242
35.197.152.14
Then create a ssh key as lines of communication with hosts that have been added
Then add the ssh copy id for each host:
root @: ~ # mulawarman ssh-copy-id root @ 103.195.5.55
root @: ~ # mulawarman ssh-copy-id root @ 35.197.152.14
root @: ~ # mulawarman ssh-copy-id root @ 35.198.213.242
Do a test against the hosts use icmp protocol (ping)
root @: ~ # mulawarman ansible-m ping powertech
103.195.5.55 | SUCCÈS = {>
"changed": false,
"failed": false,
"ping", "pong"
}
35,198,213,242. | SUCCÈS = {>
"changed": false,
"failed": false,
"ping", "pong"
}
35.197.152.14 | SUCCÈS = {>
"changed": false,
"failed": false,
"ping", "pong"
}
We can also see the use of capacity on the host filesystem using the following command:
Or can also use shell commands to view hostnames on each host
root @: ~ # mulawarman ansible-m shell-a "hostname" powertech
103.195.5.55 | SUCCÈS | RC = 0 > >
ardityo
35,198,213,242 | SUCCÈS | RC = 0 > >
powertech
35.197.152.14 | SUCCÈS | RC = 0 > >
production
The result of the output comes from the host can we save into a file using the following command:
root @: ~ # mulawarman ansible-m command-a "uname-a" powertech >/root/output.txt
Visible output files that come from the last host we see system information
Sample Script To Install Software Via Apt-Get
Create file install. yml then add the script as below:
---
-name: install zabbix-agent
Host: tyo
become: true
become_user: root
gather_facts: true
tasks:
-name: "install zabbix-agent"
apt:
name: zabbix-agent
State: lates
Sample Script To Install Software Via Wget:
---
-name: install zabbix-agent
Host: tyo
become: true
become_user: root
gather_facts: true
tasks:
-name: "install zabbix-agent"
apt:
Deb: http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix/zabbix-agent 3.4.3-2 + xenial_amd64 .deb
Example Script To Uninstall The Software:
---
-name: install zabbix-agent
Host: tyo
become: true
become_user: root
gather_facts: true
tasks:
-name: "install zabbix-agent"
apt:
pkg: "uninstall zabbix-agent"
apt:
pkg: zabbix-agent
State: absent
purge: yes
force: yes
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
@syedumair thank you
Hey @adson I am @utopian-io. I have just upvoted you!
Achievements
Suggestions
Get Noticed!
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x