我写这个是为了提取远程服务器上的文件和文件夹。它会提取它们,但不会更改提取文件的所有者和组。
---
- 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
并发现它按预期工作。
它会提取它们,但不会更改提取文件的所有者和组。
我无法产生上述问题,因为提取的文件的所有者和组发生了应有的更改。