Featured image of post Ansible-01 basic Settings

Ansible-01 basic Settings

Ansible 01 – Basic Settings

Configure ansible

  1. Create folders
1
mkdir -p playbooks/inventory
  1. Create ansible.cfg configure file
1
2
3
4
5
[defaults]
inventory = inventory/vagrant.ini
host_key_checking = False
stdout_callback = yaml
callback_enabled = timer
  1. Create inventory/vagrant.ini
1
2
3
4
5
6
7
[webservers]
testserver ansible_port=2222

[webservers:vars]
ansible_host=127.0.0.1
ansible_user=vagrant
ansible_private_key_file=.vagrant/machines/default/virtualbox/private_key

Ansilbe command

1
2
3
4
5
6
ansible testserver -m ping 
ansible testserver -m command -a uptime

ansible testserver -a "tail /var/log/dmesg"
ansible testserver -b -a "tail /var/log/dmesg"
ansible testserver -b -m service -a "name=nginx state=restarted"

Ansible Modules

Keyvalue
PackageInstalls or removes packages by using the host’s package manager
copyCopies a file from the machine where you run Ansible to the web servers
fileSets the attribute of a file, symlink, or directory
serviceStarts, stop, or restarts a service
templateGeenerates a file from a template and copies it to the hosts
1
2
A --> B
B --> C
CC BY-NC-ND
Last updated on Sep 19, 2024 09:13 UTC
Built with Hugo
Theme Stack designed by Jimmy