-1

I have a problem to expand a variable in ansible. The variable holds the path to an application folder. This should be expanded and used to run the application.

mlcp_path: '/home/<user>/mlcp-9.0.3'

shell:  "{{ mlcp_path }}/bin/mlcp.sh"  import -host {{ ml_dbserver }} .....

This results in :

shell: "{{ mlcp_path }}"/bin/mlcp.sh" import -host {{ ml_dbserver }} - port {{ ml_dbserver_port }} -username {{ ml_dbserver_user }} - input_file_path {{ mlcp_input_file_path }} -password {{ ml_dbserver_password }} -output_uri_replace "{{ mlcp_uri_replace }}" - output_permissions {{ mlcp_output_permissions }} -output_collections {{ mlcp_output_collections }} We could be wrong, but this one looks like it might be an issue with missing quotes.

In the mlcp_path variable is not used every thing works fine. I have read the docs but did not found an indication that this is incorrect. The only thing which might looks odd would be the regex later in the string. Maybe something gets out of sync?

Any hint is helpful, thanks a lot.

Michael Hoeller
  • 22,018
  • 10
  • 39
  • 66

2 Answers2

1

You have a quoting issue.

It should be something like that:

shell: "{{ mlcp_path }}/bin/mlcp.sh import -host {{ ml_dbserver }} -port {{ ml_dbserver_port }} -username {{ ml_dbserver_user }} -input_file_path {{ mlcp_input_file_path }} -password {{ ml_dbserver_password }} -output_uri_replace '{{ mlcp_uri_replace }}' -output_permissions {{ mlcp_output_permissions }} -output_collections {{ mlcp_output_collections }}"

sebthebert
  • 12,196
  • 2
  • 26
  • 37
1

Perhaps can you try to put the quotes on the full line and declare your variable as variable (to not be treated as a module):

vars: 
    mlcp_path: '/home/<user>/mlcp-9.0.3'

shell:  "{{ mlcp_path }}/bin/mlcp.sh  import -host {{ ml_dbserver }} ....."
slashcool
  • 168
  • 7