リモートサーバーのファイルとフォルダを抽出するためにこの記事を書きました。ファイルは抽出されますが、抽出されたファイルの所有者とグループは変更されません。
---
- name: Uncompressing the Tomcat source
become: true
become_user: someuser
unarchive:
src: /rmtdir/apache-tomcat-{{ VERSION }}.tar.gz
dest: /rmtdir/
owner: someuser
group: somegroup
mode: 0770
remote_src: yes
register: _extract
- name:
debug:
var: _extract
明らかに抽出されたファイルの所有者とグループを変更したいと思います。どうすればこれを行うことができますか?
ベストアンサー1
フォローアップcurl
Ansible:コマンドが失敗しました。次のテストを実行しました。
---
- hosts: test
become: true
gather_facts: false
vars:
VERSION: "9.0.65"
tasks:
- name: Uncompressing the Tomcat source
unarchive:
src: https://dlcdn.apache.org/tomcat/tomcat-9/v{{ VERSION }}/bin/apache-tomcat-{{ VERSION }}.tar.gz
dest: "/home/{{ ansible_user }}/tomcat"
owner: "{{ ansible_user }}"
group: "ansible_users"
mode: 0770
extra_opts: [--strip-components=1]
remote_src: true
environment:
http_proxy: 'localhost:3128'
https_proxy: 'localhost:3128'
register: _extract
- name: Show result
debug:
var: _extract
期待通りに動作することがわかりました。
ファイルは抽出されますが、抽出されたファイルの所有者とグループは変更されません。
抽出されたファイルの所有者とグループが正常に変更されたため、上記の問題を生成できませんでした。