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

hostname module error inside LXD containers: Failed to activate service 'org.freedesktop.hostname1': timed out #42530

Closed
selivan opened this issue Jul 9, 2018 · 6 comments
Labels
affects_2.6 This issue/PR affects Ansible v2.6 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team. system System category

Comments

@selivan
Copy link
Contributor

selivan commented Jul 9, 2018

SUMMARY

In LXD contaiers hostname module fails with error Failed to activate service 'org.freedesktop.hostname1': timed out

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hostname

ANSIBLE VERSION
ansible 2.6.1
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]
CONFIGURATION
OS / ENVIRONMENT

LXD containers host: Ubuntu 18.04 bionic
LXD version: 3.0.1
Container: Ubuntu 16.04 xenial

STEPS TO REPRODUCE
  • Launch LXD container with Ubuntu Xenial: lxc launch ubuntu:xenial mycontainer
  • Configure container host it in inventory
  • Run following task on it:
- name: update hostname
  hostname: name="container1"
EXPECTED RESULTS

Hostname should be updated

ACTUAL RESULTS
container1 | FAILED! => {
    "changed": false, 
    "invocation": {
        "module_args": {
            "name": "container1"
        }
    }, 
    "msg": "Command failed rc=1, out=, err=Could not get property: Failed to activate service 'org.freedesktop.hostname1': timed out\n"
}

hostname shell command inside container works fine, container's hostname is updated. So it's ansible module problem.

@ansibot
Copy link
Contributor

ansibot commented Jul 9, 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
Copy link
Contributor

ansibot commented Jul 9, 2018

@ansibot ansibot added affects_2.6 This issue/PR affects Ansible v2.6 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:community This issue/PR relates to code supported by the Ansible community. labels Jul 9, 2018
@webknjaz webknjaz removed the needs_triage Needs a first human triage before being processed. label Jul 10, 2018
@ansibot ansibot added support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed support:community This issue/PR relates to code supported by the Ansible community. labels Sep 20, 2018
@jjo
Copy link

jjo commented Sep 27, 2018

This seems to come from:

IMO under lxc we should fallback to non systemd hostname control
methods.

@ansibot ansibot added needs_maintainer Ansibot is unable to identify maintainers for this PR. (Check `author` in docs or BOTMETA.yml) support:community This issue/PR relates to code supported by the Ansible community. and removed support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Oct 5, 2018
@ansibot ansibot removed the needs_maintainer Ansibot is unable to identify maintainers for this PR. (Check `author` in docs or BOTMETA.yml) label Nov 9, 2018
@ansibot ansibot added the system System category label Feb 17, 2019
@ansibot ansibot added the has_pr This issue has an associated PR. label Jul 27, 2019
@ansibot ansibot added support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed support:community This issue/PR relates to code supported by the Ansible community. labels Mar 27, 2020
@ansibot
Copy link
Contributor

ansibot commented May 16, 2020

Files identified in the description:

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

click here for bot help

@relrod
Copy link
Member

relrod commented Mar 26, 2021

After discussing this in a backlog, we aren't sure there's much we can do to address this. We can't immediately fall back to not using systemd because there are cases where a container can use systemd and we would break those cases.

If you really need this, you can use a command task (assuming the container allows you to set the hostname) instead of using the hostname module.

@relrod relrod closed this as completed Mar 26, 2021
@selivan
Copy link
Contributor Author

selivan commented Mar 26, 2021

@relrod You can fall back after failing to use systemd. Something like:

  1. check that systemd is available at all, lot of container enviroments don't have it
  2. if 1 is true, try to set hostname with systemd
  3. if 1 is false or 2 failed - set it without systemd

After I committed this issue I of course used workaround. But I still think it's a good idea to fix this, rather than continue having an obvious bug.

@ansible ansible locked and limited conversation to collaborators Apr 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.6 This issue/PR affects Ansible v2.6 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team. system System category
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants