UNPKG

cfk

Version:
300 lines (251 loc) 6.19 kB
--- # Docker Setup - name: Update apt packages tags: - image - instance apt: update_cache: yes - name: Install apt https tags: image apt: name: apt-transport-https state: latest - name: Install CA certificates tags: image apt: name: ca-certificates state: latest - name: Setup docker GPG key tags: image apt_key: keyserver: hkp://pgp.mit.edu:80 id: 58118E89F3A912897C070ADBF76221572C52609D - name: Add the docker repository tags: image apt_repository: repo: deb https://apt.dockerproject.org/repo ubuntu-trusty main - name: Update apt packages (again) tags: image apt: update_cache: yes - name: Remove lxc-docker if it exists tags: image apt: name: lxc-docker state: absent purge: yes - name: Check kernel tags: image shell: uname -r register: kernel - name: Install linux image extras tags: image apt: name: linux-image-extra-{{ kernel.stdout }} state: latest - name: Install apparmor tags: image apt: name: apparmor state: latest - name: Install Docker tags: image apt: name: docker-engine=1.9.1-0~trusty state: present - name: Copy Docker Daemon Defaults tags: - image - instance template: src: defaults/docker.opts.j2 dest: /etc/default/docker - name: Copy docker cleanup job tags: image copy: src: upstart/docker-cleanup.conf dest: /etc/init/docker-cleanup.conf - name: Make sure Docker is running tags: - image - instance service: name=docker state=restarted # Install Docker Compose - name: Download Pip tags: image get_url: url: https://bootstrap.pypa.io/get-pip.py dest: /tmp/get-pip.py mode: 0755 - name: Install Pip tags: image command: python get-pip.py args: chdir: /tmp - name: Pin pip version to 7.1.2 tags: image command: pip install -I pip==7.1.2 - name: Install Docker Compose tags: image pip: name=docker-compose # Install shyaml - name: Install shyaml (for command-line yaml parsing) tags: image pip: name=shyaml - name: Make shyaml executable tags: image file: path: /usr/local/bin/shyaml mode: 0755 # Install jq - name: Install jq tags: image get_url: url: https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 dest: /usr/bin/jq mode: 0755 # Weave Setup - name: Create Weave Config Directory tags: image file: path: /etc/weave state: directory - name: Install Weave 1.4.3 tags: image command: curl -sSL https://github.com/weaveworks/weave/releases/download/v1.4.3/weave -o /usr/local/bin/weave - name: Set Weave Permissions tags: image command: chmod +x /usr/local/bin/weave - name: Setup Weave Containers tags: image command: weave setup - name: Install Weave Scope 0.12.0 tags: image command: curl -sSL https://github.com/weaveworks/scope/releases/download/v0.12.0/scope -o /usr/local/bin/scope - name: Set Weave Scope Permissions tags: image command: chmod +x /usr/local/bin/scope - name: Install Weave Discovery 0.1 tags: image command: curl -sSL https://github.com/weaveworks/discovery/releases/download/v0.1/discovery -o /usr/local/bin/discovery - name: Set Weave Discovery Permissions tags: image command: chmod +x /usr/local/bin/discovery - name: Copy Weave Startup Config tags: instance copy: src: "upstart/{{ item }}.conf" dest: "/etc/init/{{ item }}.conf" with_items: - weave - discovery - name: Copy Scope Startup Config tags: instance template: src: "upstart/scope.conf.j2" dest: "/etc/init/scope.conf" - name: Copy Weave Monitor Startup Config tags: instance copy: src: "upstart/{{ item }}-monitor.conf" dest: "/etc/init/{{ item }}-monitor.conf" with_items: - discovery - scope # Copy cfk Env Defaults - name: Copy Platform Defaults tags: instance template: src: "defaults/cfk.opts.j2" dest: "/etc/default/cfk" # Copy slack notify tasks - name: Copy Slack Notify Tasks tags: instance copy: src: "upstart/slack-notify-{{ item }}.conf" dest: "/etc/init/slack-notify-{{ item }}.conf" with_items: - startup - shutdown # Copy cfk scripts - name: Create cfk bin directory tags: instance file: path: /usr/src/cfk/bin state: directory - name: Copy cfk scripts tags: instance copy: src: "bin/{{ item }}" dest: "/usr/src/cfk/bin/{{ item }}" mode: 0700 with_items: - cfk-start - cfk-stop - cfk-env - cfk-logs - name: Symlink cfk scripts tags: instance file: src: "/usr/src/cfk/bin/{{ item }}" dest: "/usr/bin/{{ item }}" state: link with_items: - cfk-start - cfk-stop - cfk-env - cfk-logs # Load Role-Specific Services - name: Load Services tags: - image - instance include_vars: "services/{{ cfk_role }}.yml" # cfk Service Setup - name: Pull docker containers tags: image command: docker pull {{ item.value.image | regex_replace('\$\{CFK_VERSION\}', cfk_version) }} with_dict: "{{ services }}" - name: Create data directory tags: instance file: path: /data state: directory - name: Create Compose Directory tags: instance file: path: /usr/src/cfk state: directory - name: Copy Platform Docker Compose File tags: instance template: src: "services/docker-compose.yml.j2" dest: /usr/src/cfk/docker-compose.yml - name: Copy Platform Services Startup Configs tags: instance template: src: upstart/service.conf.j2 dest: /etc/init/{{ item.key }}.conf with_dict: "{{ services }}" - name: Copy Platform Services Monitor Configs tags: instance template: src: upstart/monitor.conf.j2 dest: /etc/init/{{ item.key }}-monitor.conf with_dict: "{{ services }}" - name: Copy Platform Services DNS Monitor Config tags: instance template: src: upstart/weave-monitor.conf.j2 dest: /etc/init/weave-monitor.conf # Restart all Services - name: Stop Docker tags: instance service: name=docker state=stopped - name: Start Docker tags: instance service: name=docker state=started - name: Send Bootup Notification tags: instance service: name=slack-notify-startup state=started