Background:

The K8S service is deployed on a number of hosts, but root is not granted permission. Instead of deploying dozens of hosts one by one manually, use Ansible. Save time and improve work efficiency.

Operation steps:

  1. Add common user information to the ansible. CFG configuration file, as shown in the following screenshot

Open the permission promotion comment, as shown in the figure

[privilege_escalation]

Become =True // Use “True” or “yes” to enable the privilege, e.g. : become=True to enable *****become.

Become_method =sudo *//** indicates how to switch your regular account to root or whatever other account you need, either su or sudo. *

Become_user =root *//** Set as the root account, which means that when we log in to the remote host as a common account, we run su – root to switch to the root account. *

Become_ask_pass =True *// means asking for password *

2. Run the following command on the cli:

Ansible NLP -m shell -a ‘systemctl reload docker’ -k