Thursday, April 4, 2024
Ansible

Ansible – Ad-Hoc Commands

Ad-Hoc

“Ansible – Ad-Hoc Commands “

Pengantar

Ad-Hoc Commands merupakan proses menggunakan /usr/bin/ansible (dalam hal ini command utama ansible) untuk mengotomatisasi “menjalankan secara otomatis” single task terhadap satu atau lebih node server yang dimanage.

Config Client

nano /etc/ansible/hosts

[Vmx]
maria1 ansible_host=192.168.3.5 ansible_user=root
ssh-copy-id root@192.168.3.5

Ad-Hoc Commands

1.Ping

ansible maria1 -m ping

output

maria1 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}

Atau untuk semua Vm

ansible vmx -m ping

maria1 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}

2. Update Server

ansible maria1 -m shell -a 'yum update -y' -u root

Jika membutuhkan Sudo

 ansible maria1 -m shell -a 'yum update -y' -u hendro --become -K

3. Install package

misal install httpd / apache web server

ansible maria1 -m shell -a 'yum install httpd -y'

running dan enable service

ansible maria1 -m shell -a 'systemctl start httpd'
ansible maria1 -m shell -a 'systemctl enable httpd'
ansible maria1 -m shell -a 'systemctl status httpd'

4. Reboot Server

ansible maria1 -m shell -a 'reboot'

Penutup

Sahabat Blog Learning & Doing demikianlah penjelasan mengenai Ansible – Ad-Hoc Commands . Semoga Bermanfaat . Sampai ketemu lagi di postingan berikut nya.

(Visited 192 times, 1 visits today)
Baca Juga :  Konfigurasi dan Penggunaan Ansible pada Linux Mint

Similar Posts