#day01
๐ Hi there, this is my documentation when i learning about Ansible
What is Ansible?
Ansible is an open source tool that is most used by a SysAdmin in the process of automating.
Why you should use Ansible?
Ansible is a powerful tool that you can use in the process of server management, configuration task, and other tasks. So when you use Ansible, many process such as configuration or deployment an application in server will be simple and quickly. ๐
BTW, you don't need to install Ansible on the remote hosts. You just need SSH and Python 2 or later with the Python simplejson library installed
Let's start!!
Setup
- Server side
1.Configure Network
2.Configure sudo passwordless
3.Configure SSH passwordless
- Controller
install ansible in your laptop or PC.
Linux:
$ sudo apt install software-properties-common
$ sudo add-apt-repository --yes --update ppa:ansible/ansible
$ sudo apt install ansible
MacOS:
$ brew install ansible
Okay, after installation we should make new user.
$ adduser user1
then enable passwordless sudo to this user by go to bottom line and type this:
$ sudo visudo
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
user1 ALL=(ALL:ALL) ALL
then make a new directory
$ mkdir ansible-demo
$ cd ansible-demo
after that, let's make new file with name ansible.cfg, the ansible.cfg is a brain for Ansible. Add many lines to initials an inventory
$ nano ansible.cfg
...
[defaults]
inventory = hosts # initials new file as inventory
save it and then add new file again with name hosts as an inventory file
$ nano hosts
...
[ubuntu]
srv1 ansible_user=ansible
[debian]
srv2 ansible_user=ansible
So..now your working directory look like this
/ansible-demo(main*) ยป $ tree
.
โโโ ansible.cfg
โโโ hosts
NB:
- ansible.cfg: his is the brain and the heart of Ansible, the file that governs the behavior of all interactions performed by the control node. "Redhat"
- hosts: as inventory so with 'hosts' you can managed multiple nodes at the same time.
i forgot a thing, so you also make customize at
/etc/hosts .
$ nano /etc/hosts
127.0.0.1 localhost
172.16.238.20 srv1
172.16.238.10 srv2
with this configuration makes it easier for you to do ssh with initials without using ip adddress.
$ ssh ansible@srv1
coming soon
Top comments (0)