defunctzombie / ansible-coreos-bootstrap

[NOT MAINTAINED] bootstrap a coreos machine for control via ansible

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issues starting services with Ansible

crsmithdev opened this issue · comments

I can't seem to get any services started using this approach. Playbook:

- hosts: web
  remote_user: core
  tasks:

  - name: start etcd
    service: name=etcd.service state=started

Result:

coreos-web-01 | FAILED => failed to parse: Spawning container core-crsmithdev_ubuntu-latest on /var/lib/toolbox/core-crsmithdev_ubuntu-latest.
Press ^] three times within 1s to kill container.
{"msg": "service not found: etcd.service", "failed": true}

Container core-crsmithdev_ubuntu-latest failed with error code 1.

I can systemctl start etcd.service with no issues manually, however.

Any idea what might be going on?

I think all the commands are actually running in the toolbox container. For example, if I use the "template" task it creates the dest file inside the toolbox.

yeah, that seems to be the case as well, b/c I can't even do this in ansible w/ shell: systemctl start etcd.service.

Any way to 'break out' of the toolbox container? Otherwise, what's the point of doing this w/ a toolbox?

I see that https://github.com/coreos/portage-stable/issues/59 suggests running things in raw mode...at which point i might as well not be doing this w/ Ansible. Unless there's an easy path to manually installing python on coreos, i may have to move away from coreos entirely.

@edrex when making files in the toolbox environment, you need to write them to /media/root for them to show up on the host when the toolbox exists.

@crsmithdev my initial use case for this module was to support starting docker containers (which is accomplished easily by bind mounting the docker.sock into the toolbox container. I have not yet looked at what it will take to talk to an outside systemd from inside the toolbox container but my hope is that a similar approach might work.

Alternatively, it is possible to install minimal python into the actual coreos system but this starts to get a bit tricky. If there is no nice way to make systemd to work inside the toolbox, then it might be the only way to go.

The basics of what would need to happen are to leverage some container where python is installed (ideally to /usr/local or such) and then copy those files into /home/core/usr/local (or similar) and then point the ansible python path. This can be done in the role during bootstrapping. The major gotchas to this approach is to make sure that all of the paths are updated so that when python runs it can find what it needs to find.

Hmm, that sounds like a pretty big pain, and there's other things i'd want out of Ansible + CoreOS too (copying over some settings files, etc.) I will probably switch back to running Docker on Ubuntu.

@crsmithdev yeah, I came to the same conclusion. It seems like the only proper solution would be to install a self-contained python build on the host.

I reworked how coreos can be bootstrapped and still work with Ansible. Instead of using toolboxes, I am now copying pypy onto the machine and installing pip. Python now runs on the host so you can launch services and containers. You can also install other python modules via the pip ansible module to support a wider range of actions from ansible.

8c34655

I consider this issue closed now as I was able to launch the etcd service as expected.

+1 will test Monday

The pypy bootstrap is working for me, nice.

Some Ansible modules require python modules, which seemingly can be installed with the pip module. However, some modules such as postgresql require python modules with non-python dependencies (eg psychopg) so those can't be used. This is probably alright though, since it's probably against the CoreOS Way to manage a postgresql container from the host.

I thought that module used pure python? Also might be a way to make it execute in a container for the commands it runs maybe.

@defunctzombie thanks, this is a good solution that works for everything i've thrown at it so far.