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"
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():
if self.module_args:
so in my above example this is what we end up with:
(Pdb) command Controller- 2', '-vvvvv', '--module-name', 'shell', '--args', '"hostname -s"']
['ansible', 'overcloud-
(Pdb) self.module_args
'"hostname -s"'