①copyモジュールで送信元と送信先の権限変わる件
copyモジュールを使ってファイルやディレクトリごとコピーできると思います。
例えばこんな感じのplaybookでファイル(testfile)とディレクトリ(testdir)をコピーします↓
## copy file
- name: copy file to remote
copy: src=test/{{ item }} dest=/tmp/test/ owner=user group=user mode=0775
with_items:
- testfile
- testdir
ファイルの方(testfile)はコピーできて権限も指定通りですが、
ディレクトリの方(testdir)はコピーは出来てますが権限がおかしい、、
例えば送信元がこれだった場合
[root@ansiblesvr tasks]# ls -la ../files/testdir/
合計 8
drwxr-xr-x 2 root root 4096 11月 17 10:42 2014 .
drwxr-xr-x 6 root root 4096 11月 17 10:42 2014 ..
-rwxrwxrwx 1 root root 0 11月 17 10:42 2014 aa
-rw-r--r-- 1 111 111 0 11月 17 10:42 2014 bb
-rw------- 1 root root 0 11月 17 10:42 2014 cc
送信先では
[root@stg-ansibleclient ]# ls -la testdir/
合計 8
drwxr-xr-x 2 root 111 4096 11月 9 12:33 2014 .
drwxr-xr-x 11 111 111 4096 11月 9 12:33 2014 ..
-rwxrwxr-x 1 root 111 0 11月 9 12:33 2014 aa
-rwxrwxr-x 1 root 111 0 11月 9 12:33 2014 bb
-rwxrwxr-x 1 root 111 0 11月 9 12:33 2014 cc
このパーミッション、umaskとも違うし、775はどっから持ってきてるんだろか?
※copyに以下のオプション付けても変わらなかったし
directory_mode=yes
copyモジュールでディレクトリを再帰的にコピーさせた場合に発生しましたが、
デフォルトで送信元の権限は保持してほしいな。もしくは保持するオプションが欲しい。
ってか自分のやり方が間違ってるのかな・・(ご意見ください)
なのでsynchronizeモジュールを使いました。tarで固めて送るも考えましたが、ファイルの修正時にtarで固めなきゃなので、rsyncで差分更新させるようにしました。
- synchronize: src=testdir/ dest=/tmp/ delete=yes rsync_path="/usr/bin/rsync"
あ、あと、空のディレクトリをcopyするとOKとでますが、コピーされません。。
これも軽くはまりました。ディレクトリにファイルがあればコピーされてOKと出ます。
空ディレクトリのcopyには気を付けましょう。
②serviceモジュールってchkconfig --addも兼ねてる件
service でchkconfig httpd on みたいのはできますが、
chkconfig --add httpd みたいのはできないと思って、registerやwhenやchanged_whenを駆使してshellモジュールでやろうとしてましたが、
chkconfig にadd されてない状態でも
service: name=httpd enabled=yes
を行うとaddされてるのですね。。
ドキュメントに書いてほしいな^^;
copyモジュールを使ってファイルやディレクトリごとコピーできると思います。
例えばこんな感じのplaybookでファイル(testfile)とディレクトリ(testdir)をコピーします↓
## copy file
- name: copy file to remote
copy: src=test/{{ item }} dest=/tmp/test/ owner=user group=user mode=0775
with_items:
- testfile
- testdir
ファイルの方(testfile)はコピーできて権限も指定通りですが、
ディレクトリの方(testdir)はコピーは出来てますが権限がおかしい、、
例えば送信元がこれだった場合
[root@ansiblesvr tasks]# ls -la ../files/testdir/
合計 8
drwxr-xr-x 2 root root 4096 11月 17 10:42 2014 .
drwxr-xr-x 6 root root 4096 11月 17 10:42 2014 ..
-rwxrwxrwx 1 root root 0 11月 17 10:42 2014 aa
-rw-r--r-- 1 111 111 0 11月 17 10:42 2014 bb
-rw------- 1 root root 0 11月 17 10:42 2014 cc
送信先では
[root@stg-ansibleclient ]# ls -la testdir/
合計 8
drwxr-xr-x 2 root 111 4096 11月 9 12:33 2014 .
drwxr-xr-x 11 111 111 4096 11月 9 12:33 2014 ..
-rwxrwxr-x 1 root 111 0 11月 9 12:33 2014 aa
-rwxrwxr-x 1 root 111 0 11月 9 12:33 2014 bb
-rwxrwxr-x 1 root 111 0 11月 9 12:33 2014 cc
このパーミッション、umaskとも違うし、775はどっから持ってきてるんだろか?
※copyに以下のオプション付けても変わらなかったし
directory_mode=yes
copyモジュールでディレクトリを再帰的にコピーさせた場合に発生しましたが、
デフォルトで送信元の権限は保持してほしいな。もしくは保持するオプションが欲しい。
ってか自分のやり方が間違ってるのかな・・(ご意見ください)
なのでsynchronizeモジュールを使いました。tarで固めて送るも考えましたが、ファイルの修正時にtarで固めなきゃなので、rsyncで差分更新させるようにしました。
- synchronize: src=testdir/ dest=/tmp/ delete=yes rsync_path="/usr/bin/rsync"
あ、あと、空のディレクトリをcopyするとOKとでますが、コピーされません。。
これも軽くはまりました。ディレクトリにファイルがあればコピーされてOKと出ます。
空ディレクトリのcopyには気を付けましょう。
②serviceモジュールってchkconfig --addも兼ねてる件
service でchkconfig httpd on みたいのはできますが、
chkconfig --add httpd みたいのはできないと思って、registerやwhenやchanged_whenを駆使してshellモジュールでやろうとしてましたが、
chkconfig にadd されてない状態でも
service: name=httpd enabled=yes
を行うとaddされてるのですね。。
ドキュメントに書いてほしいな^^;