Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module reboot does not work on Alpine. #46723

Closed
robertdebock opened this issue Oct 10, 2018 · 9 comments · Fixed by #49272
Closed

Module reboot does not work on Alpine. #46723

robertdebock opened this issue Oct 10, 2018 · 9 comments · Fixed by #49272
Assignees
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@robertdebock
Copy link
Contributor

SUMMARY

The reboot module does not work on Alpine and returns an error.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

reboot

ANSIBLE VERSION
$ ansible --version
ansible 2.7.0
  config file = /home/robertdb/Documents/ansible/tester/ansible.cfg
  configured module search path = [u'/home/robertdb/.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.15 (default, May 16 2018, 17:50:09) [GCC 8.1.1 20180502 (Red Hat 8.1.1-1)]
CONFIGURATION
[robertdb@robertdebock tester]$ ansible-config dump --only-changed
DEFAULT_HOST_LIST(/home/robertdb/Documents/ansible/tester/ansible.cfg) = [u'/home/robertdb/Documents/ansible/tester/inventory']
DEFAULT_ROLES_PATH(/home/robertdb/Documents/ansible/tester/ansible.cfg) = [u'/home/robertdb/Documents/ansible/tester/roles']
DEFAULT_STDOUT_CALLBACK(/home/robertdb/Documents/ansible/tester/ansible.cfg) = yaml
HOST_KEY_CHECKING(/home/robertdb/Documents/ansible/tester/ansible.cfg) = False
RETRY_FILES_ENABLED(/home/robertdb/Documents/ansible/tester/ansible.cfg) = False
OS / ENVIRONMENT

Controlnode: Fedora
Managednode: Alpine

STEPS TO REPRODUCE

Start an Alpine virtual machine:

vagrant init generic/alpine37
vagrant up

Create a playbook reboot.yml:

---
- name: reboot a machine
  hosts: all
  gather_facts: no
  become: yes

  roles:
    - role: robertdebock.bootstrap

  tasks:
    - name: reboot system
      reboot:

Install that robertdebock.bootstrap role:

ansible-galaxy install robertdebock.bootstrap

Fill an inventory:

vagrant ssh-config | grep HostName | awk '{print $2}' > inventory

Run the playbook:

ansible-playbook \
  --inventory inventory \
  --user vagrant \
  --key-file .vagrant/machines/default/libvirt/private_key \
  --extra-vars 'host_key_checking=false' \
  --extra-vars 'bootstrap_user=vagrant' reboot.yml
EXPECTED RESULTS

A wonderful reboot and lush green "ok:"s

ACTUAL RESULTS

An error: msg: '''dict'' object has no attribute ''rc'''.

The whole task:

TASK [reboot system] ***********************************************************
task path: /home/robertdb/Documents/ansible/tester/reboot.yml:11
<192.168.121.97> ESTABLISH SSH CONNECTION FOR USER: vagrant
<192.168.121.97> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=22 -o 'IdentityFile="/home/robertdb/Documents/ansible/tester/.vagrant/machines/alpine/libvirt/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/home/robertdb/.ansible/cp/6fe266fc9b -tt 192.168.121.97 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-murtlcbhremgqgaltuafsaudsxxnizur; who -b'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
<192.168.121.97> (127, '/bin/sh: who: not found\r\n', 'OpenSSH_7.8p1, OpenSSL 1.1.0h-fips  27 Mar 2018\r\ndebug1: Reading configuration data /home/robertdb/.ssh/config\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 2: Including file /etc/crypto-policies/back-ends/openssh.config depth 1\r\ndebug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config\r\ndebug3: gss kex names ok: [gss-gex-sha1-,gss-group14-sha1-]\r\ndebug3: kex names ok: [curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]\r\ndebug1: /etc/ssh/ssh_config.d/05-redhat.conf line 8: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 192.168.121.97 is address\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 6338\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 127\r\nShared connection to 192.168.121.97 closed.\r\n')
fatal: [alpine]: FAILED! => changed=false 
  msg: '''dict'' object has no attribute ''rc'''
  reboot: false
@ansibot
Copy link
Contributor

ansibot commented Oct 10, 2018

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Oct 10, 2018
@jborean93 jborean93 removed the needs_triage Needs a first human triage before being processed. label Oct 11, 2018
@samdoran
Copy link
Contributor

This particular big was fixed by 07ed487, which will be in Ansible 2.7.1.

But this still doesn't make the plugin work with Alpine Linux.

This plugin issues the command shutdown -r on Linux systems. Alpine, for some very interesting reason, ignores any parameters passed to shutdown, so this module actually shuts down the system rather than rebooting it.

To make this plugin work properly with Alpine, proper platform support needs to be added to the plugin in order to identify distribution and version. I have a WIP PR that does work with Apline Linux. I have proper platform support on the 2.8 roadmap, so this may not be fixed until 2.8. We'll see how big a change it is once I get platform support complete.

@robertdebock
Copy link
Contributor Author

@samdoran, that's more than enough. It's great that the reboot module is included in 2.7, and would be great to gradually increase the list of supported distributions.

@Trozz
Copy link
Contributor

Trozz commented Oct 17, 2018

Most linux distributions have the reboot command as well which can be used to simply reboot a system instead of shutdown -r, problem with this method is that we lose some features native of the shutdown command

@samdoran
Copy link
Contributor

samdoran commented Oct 17, 2018

@Trozz reboot is handy, but it doesn't accept as many parameters as shutdown, particularly the timeout delay.

I'm also not sure about reboot existing on *BSD, Solaris, or AIX.

@robertdebock
Copy link
Contributor Author

The code to determine how to reboot, now looks at uname.

I guess that's not sufficient to see how to reboot.

I'm not show if ansible facts like {{ ansible_distribution }} and {{ ansible_distribution_major_version }} are available, but I guess that would be a good selector. Something like this:

ansible_distribution command arguments
Alpine reboot null
CentOS shutdown -r
Debian shutdown -r
FreeBSD shutdown -r
SunOS /usr/bin/shutdown -y -r

and so on.

@samdoran
Copy link
Contributor

samdoran commented Oct 18, 2018

@robertdebock I was trying to avoid fact gathering as part of this plugin, but it now seems that is the best approach. I've found a few distributions where I need to change behavior based on the version, and getting that reliably is not easy to do with simple tools.

@samdoran
Copy link
Contributor

samdoran commented Dec 6, 2018

@robertdebock Can you please test with #49272 to see if that fixes your issue?

@ansibot
Copy link
Contributor

ansibot commented Dec 7, 2018

@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants