Chef infra 以其他用户身份运行Chef guard block
我想要一个Chef guard块,并且我想要以特定用户的身份运行该块 我知道如何以用户身份在guard中运行shell命令,因为文档中已经介绍了这一点:Chef infra 以其他用户身份运行Chef guard block,chef-infra,Chef Infra,我想要一个Chef guard块,并且我想要以特定用户的身份运行该块 我知道如何以用户身份在guard中运行shell命令,因为文档中已经介绍了这一点: not_if 'grep adam /etc/passwd', :user => 'adam' 我想改用一个保护块,这样我可以做一些更复杂的操作,并且我想以postgres用户的身份运行代码。例如: only_if do c = PGconn.connect(user: 'postgres', dbname: 'postgres')
not_if 'grep adam /etc/passwd', :user => 'adam'
我想改用一个保护块,这样我可以做一些更复杂的操作,并且我想以postgres用户的身份运行代码。例如:
only_if do
c = PGconn.connect(user: 'postgres', dbname: 'postgres')
# do some other stuff with the postgres connection
end
如何在这里分配
用户
或其他属性?代码块本身并不是以用户身份运行的,它们只是由Ruby作为用户运行。在这种情况下,您可能希望退出到psql
,并根据子流程的正常情况更改用户