geerlingguy / docker-ubuntu1804-ansible

Ubuntu 18.04 LTS (Bionic) Docker container for Ansible playbook and role testing.
https://hub.docker.com/r/geerlingguy/docker-ubuntu1804-ansible/
MIT License
78 stars 53 forks source link

Docker image missing systemctl #13

Open zoeyronain opened 5 years ago

zoeyronain commented 5 years ago

I'm trying to test out an ansible role using your docker image on Travis, however it's unable to enable UFW for the next few steps of the role.

TASK [zoeycluff.betterpress : enable UFW] ************************************** fatal: [localhost]: FAILED! => {"changed": false, "cmd": "/bin/systemctl", "msg": "Failed to connect to bus: No such file or directory", "rc": 1, "stderr": "Failed to connect to bus: No such file or directory\n", "stderr_lines": ["Failed to connect to bus: No such file or directory"], "stdout": "", "stdout_lines": []} [WARNING]: Could not create retry file '/etc/ansible/roles/zoeycluff.betterpress/tests/test.retry'. [Errno 30] Read-only file system: u'/etc/ansible/roles/zoeycluff.betterpress/tests/test.retry'

I changed the init in .travisci to "init: /sbin/init" but it's still trying to use systemctl.

Any idea what else to try? or if possible is there a when statement I can add that disables these steps only in a docker container?

the repo is https://github.com/zoeycluff/ansible-role-betterpress

I appreciate any help!

zoeyronain commented 5 years ago

12

Seems like this is related

dmlb2000 commented 4 years ago

@ZoeyCluff it's been a year so not sure if you care anymore. However, for everyone else running ansible inside of a docker container does work better with privileged mode and mounting /sys/fs/cgroup:/sys/fs/cgroup:ro into the container when running.

The alternative is to install a systemctl replacement like https://github.com/gdraheim/docker-systemctl-replacement and you can run docker containers without privileges.