Issue creating symbolic link

136 views
Skip to first unread message

lift...@gmail.com

unread,
Jan 11, 2024, 2:25:44 PM1/11/24
to Ansible Project
I know this should be trivial, but I just cannot get it to work.  I'm trying to create a symbolic link in my playbook.  I'm trying to link /etc/guacamole/guacamole.properties in the /usr/share/tomcat/.guacamole directory as follows:

- name: Config | Creating Tomcat symlink For guacamole.properties
  ansible.builtin.file:
    src: /etc/guacamole/guacamole.properties
    dest: "{{ '/usr/share/' + guacamole_tomcat + '/.guacamole' }}"
    state: link
    owner: "{{ guacamole_tomcat_user }}"
    group: "{{ guacamole_tomcat_user }}"
    mode: 0664
  notify:
    - "Restart {{ guacamole_tomcat_service }}"
    - Kill guacd
    - Restart guacd

But my playbook keeps giving me this error:

refusing to convert from directory to symlink for /usr/share/tomcat/.guacamole

Any ideas on what I'm doing wrong?

Thanks,
Harry

Dick Visser

unread,
Jan 11, 2024, 2:35:44 PM1/11/24
to ansible...@googlegroups.com
The error can't be any clearer.
The symlink you're trying to create already exists as a directory 


Sent from Gmail Mobile


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/974e3258-2936-4379-81d9-352293f9cba7n%40googlegroups.com.

lift...@gmail.com

unread,
Jan 11, 2024, 2:41:59 PM1/11/24
to Ansible Project
I'm trying to create it IN /usr/share/tomcat/.guacamole to point to /etc/guacamole/guacamole.properties.  Obviously the play isn't right, but what should it be?  Do I need to make the destination "/usr/share/tomcat/.guacamole/guacamole.properties"?  Or are the src and dest options reversed?  The /etc/guacamole/guacamole.properties is a file and not a directory.

Thanks,
Harry

Todd Lewis

unread,
Jan 11, 2024, 2:50:22 PM1/11/24
to Ansible Project
dest: "{{ '/usr/share/' + guacamole_tomcat + '/.guacamole/guacamole.properties' }}"

Todd Lewis

unread,
Jan 11, 2024, 2:53:51 PM1/11/24
to Ansible Project
You can think of them as reversed if it will help you understand it.

As for the ansible.builtin.file module, the "path" (alias "dest") is the thing you are creating / modifying / deleting. "src" is what the ASCII arrow points to when you do "ls -l" on the command line.

Todd Lewis

unread,
Jan 11, 2024, 3:15:47 PM1/11/24
to Ansible Project
If you think of "src" as "one end of the 'ls -l' arrow", then they are certainly reversed.
But if you think of "src" as "the source of data when reading from the link", then "src" makes sense. The "dest" becomes "the place to create the link itself."

Dick Visser

unread,
Jan 11, 2024, 3:17:22 PM1/11/24
to ansible...@googlegroups.com
On Thu, 11 Jan 2024 at 20:50, Todd Lewis <uto...@gmail.com> wrote:
dest: "{{ '/usr/share/' + guacamole_tomcat + '/.guacamole/guacamole.properties' }}"

With the strings defined outside the jinja block, it's a bit clearer:

dest: "/usr/share/{{ guacamole_tomcat }}/.guacamole/guacamole.properties"




 

harry devine

unread,
Jan 11, 2024, 3:31:39 PM1/11/24
to ansible...@googlegroups.com
Got it!  That cleared up my confusion and it's working now.  I.appreciate you guys setting me straight!

Thanks,
Harry

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages