【问题标题】:Ansible shell comand with root elevation具有根提升的 Ansible shell 命令
【发布时间】:2017-04-20 09:45:45
【问题描述】:

我使用以下命令在我的机器中搜索特定数据:

ansible -i [inventory_name].inventory [inventory group] -m shell -a "grep 'PermitRootLogin' /etc/ssh/sshd_config" 

但是现在,我需要将用户提升为 root(以查看文件的内容)。可以在同一命令行中吗?我该怎么做?

【问题讨论】:

    标签: shell command-line ansible root elevation


    【解决方案1】:

    ansible --help 建议:

    权限提升选项:

    -b, --become        run operations with become (does not imply password
                        prompting)
    

    【讨论】:

    • 怎么回事?我每天都用它。
    • 我使用:ansible -vvvv -i totalv1_PAC.inventory serverstest -m shell -a -b "grep 'PermitRootLogin' /etc/ssh/sshd_config"
    • 这样你将shell字符串作为值传递给-b参数而不是-a。试试看:ansible -i totalv1_PAC.inventory serverstest -m shell -b -a "grep 'PermitRootLogin' /etc/ssh/sshd_config"
    • ansible -i totalv1_PAC.inventory serverstest -m shell -b -a "grep 'PermitRootLogin' /etc/ssh/sshd_config" 用法:ansible [options] ansible: error: no这样的选项:-b 可能,我需要在任何地方指定“-b”参数...我真的不知道...
    • 你使用什么 Ansible 版本?
    猜你喜欢
    • 2014-09-04
    • 2013-12-09
    • 1970-01-01
    • 1970-01-01
    • 2019-10-05
    • 2018-04-03
    • 1970-01-01
    • 2014-10-15
    • 1970-01-01
    相关资源
    最近更新 更多