0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ansible - Sudoが使えない時

Last updated at Posted at 2015-03-22

Ansibleを触っていて困ったのは、既存のサーバ群のセキュリティが強固な時でした。
強固というか、sudoersに各シェル(sh,bash)を使わせない設定になっていたので
Ansibleの挙動的に、指定されたシェルを使ってrootにスイッチ?かsudoを叩いていたのですが
どうやらそれにひっかかっていた模様・・・

Ansibleの設定でどうこう、では無く力技で回避させたので備忘録で残しておきます。

usesudo.sh
# !/bin/sh
### 引数にsudoで実行したいコマンドを引き渡す

password=yourpassword

expect -c "

spawn sudo $*
set timeout 30
expect password:
send $password
"
executewithsudo.yml
 - hosts: sample
   user: user
   sudo: no

   tasks:
    - name: copy "usesudo.sh"
      copy: src=/tmp/usesudo.sh dest=/tmp/usesudo.sh
    - name: chmod
      command: chmod +x /tmp/usesudo.sh
    - name: execute command
      command: /tmp/usesudo.sh "yum update bash -y"
    - name: remove dangerous file
      file: path=/tmp/usesudo.sh state=absent

しかしshも使わせない設計とは・・・

0
0
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?