Monday, November 11, 2024
Ansible Linux Mint Playbook

Konfigurasi dan Penggunaan Ansible pada Linux Mint

penggunaan

“Konfigurasi dan Penggunaan Ansible pada Linux Mint”

Pengantar

Setelah sebelum nya saya bahas mengenai Cara Install Ansible pada Linux Mint 20 , kemudian kita coba setting konfigurasi dan coba gunakan ansibel pada linux mint.

Siapkan infra

Ansible controller node

Ansible Host Nodes

  • node1: 192.168.100.28
  • node2: 192.168.100.33

Copy ssh key ke node client

ssh-copy-id root@192.168.100.28
ssh-copy-id root@192.168.100.33

Install Package berikut di semua node

sudo apt install openssh-server
sudo systemctl start ssh
sudo systemctl enable ssh
sudo ufw allow ssh
sudo ufw enable

Konfigurasi Ansible di control node (192.168.100.34)

sudo vim /etc/ansible/hosts

Test ping ( adhoc )

ansible all -m ping -u root
ansible node1 -m ping -u root
  • Cek space pada node1
ansible node1 -a "df -h" -u root
ansible all -m apt -a "upgrade=yes update_cache=yes" --become -K

Membuat Playbook

sudo vim /etc/ansible/users.yml
- hosts: all
  vars:
         users:
         - lorn
         - tiff
         - haile
  tasks:
         - name: "Create admin group"
           become: "true"
           group:
                    name: "admin"
                    state: "present"
         - name: "Create users and add users to groups"
           become: "true"
           user:
                    name: "{{ item }}"
                    groups: "admin"
                    append: "true"
                    create_home: "true"
           with_items: "{{ users }}
         - name: "Give admin users sudo privileges without password prompt"
           become: "true"
           lineinfile:
                    dest: "/etc/sudoers"
                    state: "present"
                    regexp: "^%admin"
                    line: "%admin ALL=(ALL) NOPASSWD: ALL"
cd /etc/ansible
ansible-playbook users.yml

Penutup

Sahabat Blog Learning & Doing demikianlah penjelasan mengenai Konfigurasi dan Penggunaan Ansible pada Linux Mint. Semoga Bermanfaat . Sampai ketemu lagi di postingan berikut nya.

(Visited 146 times, 1 visits today)

Similar Posts