Reputation: 53
I am creating a role to deploy Jira instance. My question is, how I can move files from one directory to another, I was trying something like this:
- name: Create Jira installation directory
command: mv "/tmp/atlassian-jira-software-{{ jira_version }}-standalone/*" "{{ installation_directory }}"
when: not is_jira_installed.stat.exists
But It's not working, I want to copy all files from one directory to another without copying the directory.
Upvotes: 1
Views: 1618
Reputation: 39264
From the synopsis of the command
module:
The command(s) will not be processed through the shell, so variables like
$HOSTNAME
and operations like"*"
,"<"
,">"
,"|"
,";"
and"&"
will not work. Use the ansible.builtin.shell module if you need these features.
So, your issue is the fact that the command
module is not expanding the wildcard *
, as you expect it, you should be using the shell
module instead:
- name: Create Jira installation directory
shell: "mv /tmp/atlassian-jira-software-{{ jira_version }}-standalone/* {{ installation_directory }}"
when: not is_jira_installed.stat.exists
Now, please note that you can also make this without having to resort to a command
or shell
, by using the copy
module.
- copy:
src: "/tmp/atlassian-jira-software-{{ jira_version }}-standalone/"
dest: "{{ installation_directory }}"
remote_src: yes
Upvotes: 2