我正在创建一个库存文件,我也希望成为root用户,但是为了这样做,我需要在节点上使用这个确切的命令:
sudo rootsh -i -u root
有办法吗?
后来我想把这个库存用于这个命令或接近它的东西:
ansible -i inventory_file -m setup -a 'filter=ansible_virtualization_role' -o -b all
谢谢。
要在清单文件中提到的节点上运行任何“sudo”命令,您必须通过添加以下内容来升级“ansible.cfg”文件中的权限:
'成为=真'
您可以从here.了解有关Ansible Privilege Escalation Settings的更多信息
或者你也可以在你的ansible playbook任务中明确提到它,如下所示:
- name: execute this command
command: "rootsh -i -u root"
become: true
不是解决这个问题的解决方案。
我无法找到将其放入库存文件的解决方案,并且出现了有关使用的其他问题。