Ansible: extract archive to user's dir

2019-03-05 22:59发布

问题:

I'm trying to build an ansible playbook which extracts an archive (available through http) under a folder to be created in the user's home directory. So far I've come up with:

- name: Extract archive
  unarchive:
          creates: wildfly
          src: "http://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.zip"
          dest: "{{ ansible_user_dir }}"/wildfly
          remote_src: yes

However by running it, I get a syntax error: here is the offending line:

dest: "{{ ansible_user_dir }}"/wildfly
                              ^ here

I've tried also without quotes, but the issue stays the same. By hardcoding the user's home dir it works- except that no folder "wildfly" is created. Any help ?

回答1:

Quote the whole expression:

dest: "{{ ansible_user_dir }}/wildfly"