I solved the problem. In addition to defining the variable {{
was_updi_update_sh }} in the vars/worklight.yml file I was also using the
same name to register the output of a file test (testing whether that file
existed). By the time the command was being executed the content of the
variable {{ was_updi_update_sh }} had changed.
On Tuesday, March 1, 2016 at 4:33:30 PM UTC-5, David MacBride wrote:
>
> I'm running some sudo commands via the command module. In one of the
> commands, when I use a variable to specify the path to a script there is an
> error during the variable substitution and the command fails. In some
> commands, the variable substitution works while in one it doesn't. I have
> not determined what is different between the examples that work and those
> that do not.
>
> Here is more detail:
>
> When I run a playbook containing the following two commands
> command: "sudo -u wasadmin {{ was_install_dir }}/profiles/{{
> was_profile_name }}/bin/stopServer.sh {{ was_server_name }}"
> command: "sudo -u wasadmin /opt/IBM/WebSphere/UpdateInstaller/update.sh
> -silent -options {{ was_maintenance_response_file }}"
>
> ... both commands run successfully on the remote host. The output of the
> playbook shows that the correct commands are run:
> TASK: [worklight_maintenance | Stop the application server]
> *******************
> <remote.host.name> REMOTE_MODULE command sudo -u wasadmin
> /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/stopServer.sh server1
>
> TASK: [worklight_maintenance | Apply WAS maintenance]
> *************************
> <remote.host.name> REMOTE_MODULE command sudo -u wasadmin
> /opt/IBM/WebSphere/UpdateInstaller/update.sh -silent -options
> /opt/build/maintenance/was.maintenance.rsp
>
> But when I change the second command to also use a variable in place of
> the full path to the script, like so (see highlighed change):
> command: "sudo -u wasadmin {{ was_install_dir }}/profiles/{{
> was_profile_name }}/bin/stopServer.sh {{ was_server_name }}"
> command: "sudo -u wasadmin {{ was_updi_update_sh }} -silent -options {{
> was_maintenance_response_file }}"
>
> ... the second command doesn't run successfully. In the playbook output
> we see that the substitution of the variable {{ was_updi_update_sh }} has
> gone terribly wrong as shown by the highlighted section.
> <ecwlapp1qa4.hhgregg.com> REMOTE_MODULE command sudo -u wasadmin
> /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/stopServer.sh server1
> <ecwlapp1qa4.hhgregg.com> REMOTE_MODULE command sudo -u wasadmin
> {'invocation':
> {'module_name': u'stat', 'module_complex_args': {}, 'module_args':
> u'path=/opt/IBM/WebSphere/UpdateInstaller/update.sh'}, 'stat': {'uid': 522,
> 'exists': True, 'woth': False, 'mtime': 1442612966, 'inode': 5931018,
> 'isgid': False, 'size': 1286, 'isuid': False, 'isreg': True, 'pw_name':
> 'wasadmin', 'gid': 522, 'ischr': False, 'wusr': True, 'xoth': True, 'rusr':
> True, 'nlink': 1, 'issock': False, 'rgrp': True, 'gr_name': 'wasadmin',
> 'path': '/opt/IBM/WebSphere/UpdateInstaller/update.sh', 'xusr': True,
> 'atime': 1456861468, 'md5': '142ed49388e43e9f2a7174e9f0974809', 'isdir':
> False, 'ctime': 1442612966, 'isblk': False, 'wgrp': False, 'xgrp': True,
> 'dev': 64773, 'roth': True, 'isfifo': False, 'mode': '0755', 'checksum':
> '3f15c2e57403d7d38d5ab5e1111fbc6b3f9c62e5', 'islnk': False}, 'changed':
> False} -silent -options /opt/build/maintenance/was.maintenance.rsp
>
>
> The variables are all defined in the same way. They are defined in a file
> like so:
> -sh-4.1$ cat roles/worklight_maintenance/vars/worklight.yml
> ---
> was_updi_update_sh: /opt/IBM/WebSphere/UpdateInstaller/update.sh
> was_install_dir: /opt/IBM/WebSphere/AppServer
> was_profile_name: AppSrv01
> was_server_name: server1
> -sh-4.1$
>
> The file with the variables is included in the tasks.yml file like so:
> - name: Include variables
> include_vars: ../vars/worklight.yml
>
>
> The controller is a RHEL v6.3 host running Ansible v1.9.4
>
> Should I open a bug in GitHub?
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/38573bb6-8192-41bb-b0dd-18b05c59d27e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.