2018-11-27 07:46:47 |
Radoslaw Smigielski |
description |
tripleo_common/actions/ansible.py AnsibleAction class provides a wrapper around ansible executable (not ansible-playbook). Normal ansible command allows to execute add hoc commands like below:
> ansible overcloud-Controller-2 --module-name shell --args "hostname"
This is fully working but when remote command is going to have any param/switch this fails, example:
> ansible overcloud-Controller-2 --module-name shell --args "hostname -s"
The problem is that in AnsibleAction class --args is always treated as JSON and converted to string with json.dumps():
self.module_args = self._kwargs_for_run.pop('module_args', None)
if self.module_args:
self.module_args = json.dumps(self.module_args)
so in my above example this is what we end up with:
(Pdb) command
['ansible', 'overcloud-Controller-2', '-vvvvv', '--module-name', 'shell', '--args', '"hostname -s"']
(Pdb) self.module_args
'"hostname -s"' |
tripleo_common/actions/ansible.py AnsibleAction class provides a wrapper around ansible executable (not ansible-playbook). Normal ansible command allows to execute add hoc commands like below:
> ansible overcloud-Controller-2 --module-name shell --args "hostname"
> ansible overcloud-Controller-2 --args "hostname"
This is fully working but when remote command is going to have any param/switch this fails, example:
> ansible overcloud-Controller-2 --module-name shell --args "hostname -s"
The problem is that in AnsibleAction class --args is always treated as JSON and converted to string with json.dumps():
self.module_args = self._kwargs_for_run.pop('module_args', None)
if self.module_args:
self.module_args = json.dumps(self.module_args)
so in my above example this is what we end up with:
(Pdb) command
['ansible', 'overcloud-Controller-2', '-vvvvv', '--module-name', 'shell', '--args', '"hostname -s"']
(Pdb) self.module_args
'"hostname -s"' |
|