We earn commission when you buy through affiliate links.
This does not influence our reviews or recommendations.Learn more.
It is multi-platform and can work with most modern operating systems, including Linux, Windows, and Mac.
It supports a declarative language written inYAMLorYAML Ain’t Markup Languageto describe system configuration.
Ansible, along with other modern configuration management platforms, has revolutionized IT automation and industry standards.
Not only for DevOps, but Ansible can also help automate many day-to-day tasks done by aSystem Administrator.
Ansiblecopymodule can help you do these tasks in aplaybook.
One such task is to know server uptime.
With Ansible, we can easily fetch uptime values and print them together.
Different Ansible module makes this possible.
An entry in/etc/fstabis also created through temporary or permanent mount depending on module options.
Ansible allows the collection oflogsfrom different servers in your enterprise environment and keeps them in your defined location easily.
We may also need to remove certain packages which are no longer needed or have some critical bugs etc.
Heres an example demonstrating the installation and removal of one package each forUbuntuand RHEL/CentOS-based Linux servers.
Managing users
Users and groups form the basic structure around which Unix/Linux-based systems manage access and permissions.
Heres a simple example that shows the creation and deletion of users and groups using Ansible.
After this playbook runs, target servers will havegroupAandgroupBcreated with given GIDs whileuser1will be removed, if present.
A new user without a shell will be created asuser2with given UID, groups assigned, and locked password.
Managing services
Services are process daemons that run in the background and serve some service likesshdprovidingSSHconnectivity etc.
Thehttpddaemon is started towards the end.
Do remember to check service name as different Linux distributions use other names even for the same service likesshandsshd.
To read more about Ansible and its extensive set of modules, refer to itsdocumentation.