Ansible¶
Installation¶
Configuration file structure¶
- ANSIBLE_CONFIG (env variable)
- ./ansible.cfg (An ansible.cfg file, in the current directory) -- PREFERED WAY --
- ~/.ansible.cfg (Hidden file in the home directory)
- /etc/ansible/ansible.cfg
Register Ansible hosts¶
Manual¶
Configuring SSH connectivity between hosts
Generate ssh-keygen¶
Copy public key to hosts (manual way)¶
ssh-copy-id -o StrictHostKeyChecking=no ansible@host1
ssh-copy-id -o StrictHostKeyChecking=no ansible@host2
ssh-copy-id -o StrictHostKeyChecking=no ansible@host3
ssh-copy-id -o StrictHostKeyChecking=no ansible@server1
ssh-copy-id -o StrictHostKeyChecking=no ansible@server2
ssh-copy-id -o StrictHostKeyChecking=no ansible@server3
Automated way¶
Install Package¶
Create password file¶
Run script to register sshkey into hosts and servers (ansible and root user)¶
for user in ansible root
do
for os in host server
do
for instance in 1 2 3
do
sshpass -f password.txt ssh-copy-id -o StrictHostKeyChecking=no ${user}@${os}${instance}
done
done
done
Check if hosts are up and config is valid¶
Commands¶
- Ping all hosts / groups
-
Better interface (add -o in the end)
-
List hosts
-
Overwrite variable