vmware.coreos-bootstrap

Build Status

IMPORTANT: After Ansible version 2.1, you can no longer use this method:

ansible_python_interpreter="PATH=/home/core/bin:$PATH python"

The good news is that this method is not needed anymore. Now you can simply use:

ansible_python_interpreter="/home/core/bin/python"

This works with both old and new versions of Ansible and is easier.

coreos-bootstrap

To run Ansible effectively, the target machine must have a Python interpreter. CoreOS machines are minimal and do not include Python. To address this, we can install pypy, which is a lightweight Python interpreter. The coreos-bootstrap role will install pypy for you, and we will update our inventory file to use this interpreter.

Current version: 0.6.3

Installation

To install the coreos-bootstrap role, run:

ansible-galaxy install vmware.coreos-bootstrap

Configuring Your Project

Unlike a regular role, you need to set Ansible to use a different Python interpreter for CoreOS hosts. You can do this by adding a coreos group to your inventory file and setting the group's variables to use the new Python interpreter. This lets you manage both CoreOS and non-CoreOS hosts. Just place any CoreOS host in the coreos group, and it will automatically use the specified Python interpreter.

Example inventory file:

[coreos]
host-01
host-02

[coreos:vars]
ansible_ssh_user=core
ansible_python_interpreter="/home/core/bin/python"

This sets Ansible to use the Python interpreter located at /home/core/bin/python, which the coreos-bootstrap role will create.

Bootstrap Playbook

Next, add the following to your playbook file and include it in your site.yml so it runs on all hosts in the coreos group.

- hosts: coreos
  gather_facts: False
  roles:
    - vmware.coreos-bootstrap

Ensure gather_facts is set to false; otherwise, Ansible will try to gather system information using Python, which isn't installed yet!

Example Playbook

After bootstrapping, you can use Ansible as usual to manage services, install Python modules (using pip), and run containers. Below is a simple example that starts the etcd service, installs the docker-py module, and uses the Ansible docker module to pull and start an nginx container.

- name: Nginx Example
  hosts: web
  tasks:
    - name: Start etcd
      service: name=etcd.service state=started
      sudo: yes
      sudo_user: root

    - name: Install docker-py
      pip: name=docker-py

    - name: Pull container
      raw: docker pull nginx:1.7.1

    - name: Launch nginx container
      docker:
        image="nginx:1.7.1"
        name="example-nginx"
        ports="8080:80"
        state=running

License

MIT

Informazioni sul progetto

CoreOS bootstrap

Installa
ansible-galaxy install vmware.coreos-bootstrap
Licenza
mit
Download
9.8k
Proprietario