2016-04-05 18 views
4

rootとしてさまざまな作業を実行する必要がありますが、セキュリティ上の制約のため、「super su-root」コマンドを実行してパスワードを入力するだけです。 sudoは許可されていません。このようなログイン後にユーザーを切り替えることは可能ですか?ログイン後にユーザーを切り替える

+0

あなたのバージョンは何ですか? – helloV

+0

ソースからビルドするので、最新です。 –

答えて

1

はい、それは可能である:

Directives 

These can be set from play to task level, but are overriden by connection variables as they can be host specific. 

become 
set to ‘true’/’yes’ to activate privilege escalation. 

become_user 
set to user with desired privileges, the user you ‘become’, NOT the user you login as. Does NOT imply become: yes, to allow it to be set at host level. 

become_method 
at play or task level overrides the default method set in ansible.cfg, set to ‘sudo’/’su’/’pbrun’/’pfexec’/’doas’ 

Connection variables 
Each allows you to set an option per group and/or host, these are normally defined in inventory but can be used as normal variables. 

ansible_become 
equivalent of the become directive, decides if privilege escalation is used or not. 

ansible_become_method 
allows to set privilege escalation method 

ansible_become_user 
allows to set the user you become through privilege escalation, does not imply ansible_become: True 

ansible_become_pass 
allows you to set the privilege escalation password 

http://docs.ansible.com/ansible/become.html

+0

sudoの形式が必要です(つまり、別のユーザーとしてコマンドを実行しますが、ユーザーを切り替える必要はありません)。 "super su-root"コマンドを使用して他のタスクを実行する前に、実際にrootに切り替える必要があります。 –

0

はAnsibleは、このようなユースケースをサポートするために、正確にthe become generic privilege escalation methodsudoを使用してから移行されました。

superコマンドにはanother become_methodを実装する必要があります。そうでない場合は、Ansibleチームに依頼してください。

+0

ここでは「う」とは思えません。あなたのリンクから: "特権エスカレーション方法(デフォルト= sudo)、有効な選択肢:[sudo | su | pbrun | pfexec | doas]"。このために任意のコマンドを設定することはできません。 – tubaguy50035

+0

そうです、私は、OPが彼らのコマンドをサポートしていることを示唆しています。それぞれの実装はかなり単純な線でしかないようですが、ソースから安全なものを構築しているので、明らかに理想的なソリューションではありませんが、その状況を処理するのが最も簡単かもしれません。 –

+0

これは、文書化されていない機能である 'become_exe'を使用することで既に可能ですが、私は実現パラダイムを使用できないため、問題は解決しません。私が持っているコマンドは、別のユーザーとしてコマンドを実行するのではなく、ユーザーを切り替えます。 –

関連する問題