Ansible installation¶
Ansible version need above 2.12+
1. User creation¶
- 1.1 User config (Rocky)
Login with root, and check whether the ansible user exists.
If user does not exist, please create it
Grant sudo permission to ansible user
- 1.2 User config (Ubuntu)
Login with root, and check whether the ansible user exists.
Grant sudo permission to ansible user
2. Ansible install¶
- 2.1 Install ansible (Rocky)
Config proxy to install ansible (if need)
Install ansible
Install ansible extension plug-in
su - ansible
export http_proxy="http://10.xx.xx.xx:xx"
export https_proxy="http://10.xx.xx.xx:xx"
ansible-galaxy collection install ansible.posix
ansible-galaxy collection install community.general
- 2.2 Install ansible (Ubuntu)
Config proxy to install ansible (if need)
Install ansible
Install ansible extension plug-in
su - ansible
export http_proxy="http://10.xx.xx.xx:xx"
export https_proxy="http://10.xx.xx.xx:xx"
ansible-galaxy collection install ansible.posix
ansible-galaxy collection install community.general
3. Ansible config¶
- 2.1 Create config file
Add below parameters to ansible.cfg file (check/change remote user to your remote maintain user)
[defaults]
inventory = ./hosts
roles_path = ./cog-ansible/roles
remote_user = ansible
host_key_checking = False
forks = 20
[privilege_escalation]
become=True
become_method=sudo
become_user=root
become_ask_pass=False
- 2.2 Create inventory file
Add the agent host info into hosts file
[group1]
apserver ansible_ssh_host=10.41.xx.xx
[group2]
dbserver ansible_ssh_host=10.41.xx.xx
[group:children]
group1
group2
[all:vars]
ansible_ssh_pass="remote_user_password"
ansible_sudo_pass="remote_user_password"
- 2.3 Check ansible version
- 2.4 Prepare ssh key
Create public and private key in remote user home folder


