├── .editorconfig ├── .travis.yml ├── LICENSE ├── README.md ├── files ├── bootstrap.sh ├── get-pip.py └── runner ├── meta └── main.yml ├── tasks └── main.yml └── tests └── test.yml /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | indent_style = space 11 | indent_size = 2 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: python 3 | python: "2.7" 4 | 5 | env: 6 | - SITE=test.yml 7 | 8 | before_install: 9 | - sudo apt-get update -qq 10 | - sudo apt-get install -y curl 11 | 12 | install: 13 | - pip install ansible 14 | 15 | # Add ansible.cfg to pick up roles path. 16 | - "printf '[defaults]\nroles_path = ../' > ansible.cfg" 17 | 18 | script: 19 | - "ansible-playbook -i tests/inventory tests/$SITE --syntax-check" 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Roman Shtylman 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This project is no longer maintained # 2 | 3 | # coreos-bootstrap 4 | 5 | In order to effectively run ansible, the target machine needs to have a python interpreter. Coreos machines are minimal and do not ship with any version of python. To get around this limitation we can install [pypy](http://pypy.org/), a lightweight python interpreter. The coreos-bootstrap role will install pypy for us and we will update our inventory file to use the installed python interpreter. 6 | 7 | # install 8 | 9 | ``` 10 | ansible-galaxy install defunctzombie.coreos-bootstrap 11 | ``` 12 | 13 | # Configure your project 14 | 15 | Unlike a typical role, you need to configure Ansible to use an alternative python interpreter for coreos hosts. This can be done by adding a `coreos` group to your inventory file and setting the group's vars to use the new python interpreter. This way, you can use ansible to manage CoreOS and non-CoreOS hosts. Simply put every host that has CoreOS into the `coreos` inventory group and it will automatically use the specified python interpreter. 16 | ``` 17 | [coreos] 18 | host-01 19 | host-02 20 | 21 | [coreos:vars] 22 | ansible_ssh_user=core 23 | ansible_python_interpreter=/home/core/bin/python 24 | ``` 25 | 26 | This will configure ansible to use the python interpreter at `/home/core/bin/python` which will be created by the coreos-bootstrap role. 27 | 28 | ## Bootstrap Playbook 29 | 30 | Now you can simply add the following to your playbook file and include it in your `site.yml` so that it runs on all hosts in the coreos group. 31 | 32 | ```yaml 33 | - hosts: coreos 34 | gather_facts: False 35 | roles: 36 | - defunctzombie.coreos-bootstrap 37 | ``` 38 | 39 | Make sure that `gather_facts` is set to false, otherwise ansible will try to first gather system facts using python which is not yet installed! 40 | 41 | ## Example Playbook 42 | 43 | After bootstrap, you can use ansible as usual to manage system services, install python modules (via pip), and run containers. Below is a basic example that starts the `etcd` service, installs the `docker-py` module and then uses the ansible `docker` module to pull and start a basic nginx container. 44 | 45 | ```yaml 46 | - name: Nginx Example 47 | hosts: web 48 | sudo: true 49 | tasks: 50 | - name: Start etcd 51 | service: name=etcd.service state=started 52 | 53 | - name: Install docker-py 54 | pip: name=docker-py 55 | 56 | - name: pull container 57 | raw: docker pull nginx:1.7.1 58 | 59 | - name: launch nginx container 60 | docker: 61 | image="nginx:1.7.1" 62 | name="example-nginx" 63 | ports="8080:80" 64 | state=running 65 | ``` 66 | 67 | # License 68 | MIT 69 | -------------------------------------------------------------------------------- /files/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | 3 | set -e 4 | 5 | cd 6 | 7 | if [[ -e $HOME/.bootstrapped ]]; then 8 | exit 0 9 | fi 10 | 11 | PYPY_VERSION=5.1.0 12 | 13 | if [[ -e $HOME/pypy-$PYPY_VERSION-linux64.tar.bz2 ]]; then 14 | tar -xjf $HOME/pypy-$PYPY_VERSION-linux64.tar.bz2 15 | rm -rf $HOME/pypy-$PYPY_VERSION-linux64.tar.bz2 16 | else 17 | wget -O - https://bitbucket.org/pypy/pypy/downloads/pypy-$PYPY_VERSION-linux64.tar.bz2 |tar -xjf - 18 | fi 19 | 20 | mv -n pypy-$PYPY_VERSION-linux64 pypy 21 | 22 | ## library fixup 23 | mkdir -p pypy/lib 24 | [ -f /lib64/libncurses.so.5.9 ] && ln -snf /lib64/libncurses.so.5.9 $HOME/pypy/lib/libtinfo.so.5 25 | [ -f /lib64/libncurses.so.6.1 ] && ln -snf /lib64/libncurses.so.6.1 $HOME/pypy/lib/libtinfo.so.5 26 | 27 | mkdir -p $HOME/bin 28 | 29 | cat > $HOME/bin/python <