Skip to content
This repository has been archived by the owner on Jul 9, 2020. It is now read-only.

Ansible power action should use shell module #592

Merged
merged 1 commit into from Apr 7, 2020

Conversation

snagoor
Copy link
Contributor

@snagoor snagoor commented Jun 26, 2019

Tested with the simple Ansible playbook

- hosts: rhel8.acme.lab
  tasks:
    - command: |
        echo restart host && sleep 3
        shutdown -r +1
ansible-playbook -i /tmp/host reboot.yaml --ask-pass -e 'ansible_python_interpreter=/usr/libexec/platform-python'
SSH password: 

PLAY [rhel8.acme.lab] ******************************************************************************************************************************************************

TASK [Gathering Facts] *****************************************************************************************************************************************************
ok: [rhel8.acme.lab]

TASK [command] *************************************************************************************************************************************************************
changed: [rhel8.acme.lab]

PLAY RECAP *****************************************************************************************************************************************************************
rhel8.acme.lab             : ok=2    changed=1    unreachable=0    failed=0   

From /var/log/messages on the client system

Jun 26 01:36:36 rhel8 ansible-command[1592]: Invoked with _raw_params=echo restart host && sleep 3#012 shutdown -r +1 warn=True _uses_shell=False argv=None chdir=None executable=None creates=None removes=None stdin=None

Host didn't reboot, but the job was successful.

After changing the command module to shell and re-ran the job, following was captured in /var/log/messages

Jun 26 01:58:05 rhel8 ansible-command[1496]: Invoked with _uses_shell=True _raw_params=echo restart host && sleep 3#012 shutdown -r +1 warn=True argv=None chdir=None executable=None creates=None removes=None stdin=None

And host rebooted successfully after a minute.

@theforeman-bot
Copy link
Member

@snagoor, the Redmine ticket used is for a different project than the one associated with this GitHub repository. Please either:

If changing the ticket number used, remember to update the PR title and the commit message (using git commit --amend).


This message was auto-generated by Foreman's prprocessor

@snagoor snagoor changed the title Fixes #591 - Ansible power action should use shell module Ansible power action should use shell module Jun 26, 2019
@theforeman-bot
Copy link
Member

@snagoor, the Redmine ticket used is for a different project than the one associated with this GitHub repository. Please either:

If changing the ticket number used, remember to update the PR title and the commit message (using git commit --amend).


This message was auto-generated by Foreman's prprocessor

@snagoor
Copy link
Contributor Author

snagoor commented Jun 26, 2019

Additional information regarding the Ansible version used for this test

# ansible --version
ansible 2.6.17
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Jun 11 2019, 12:19:05) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

Copy link

@shiramax shiramax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @snagoor, I've tested it and it works great!

@shiramax shiramax merged commit 35ea654 into theforeman:develop Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants