Skip to content

Instantly share code, notes, and snippets.

@showaltb
Created November 4, 2016 13:14
Show Gist options
  • Save showaltb/83caf070283072a7f268f2b612d3ac6f to your computer and use it in GitHub Desktop.
Save showaltb/83caf070283072a7f268f2b612d3ac6f to your computer and use it in GitHub Desktop.
Ansible playbook to provision a tinyproxy server on an Ubuntu or CentOS (7.1+) host
# provision a tinyproxy server on an Ubuntu or CentOS (7.1+) host
- hosts: proxies
become: true
roles:
- geerlingguy.firewall
vars:
firewall_allowed_tcp_ports: [ 22, 8888 ]
tasks:
- name: Install curl
package:
name: curl
state: installed
- name: Check if docker is installed
command: docker info
register: docker_installed
failed_when: docker_installed.rc > 2
changed_when: no
- name: Install Docker
shell: curl -sSL https://get.docker.com/ | sh
when: docker_installed.rc != 0
- name: Add epel repository (CentOS)
package:
name: epel-release
state: latest
when: ansible_distribution == 'CentOS'
- name: Install pip
package:
name: python-pip
state: latest
- name: Upgrade latest pip, setuptools, and docker-compose
pip:
name: "{{ item.name }}"
state: latest
with_items:
- { name: pip }
- { name: setuptools }
- { name: docker-compose }
# docker-py version 1.10 fails incorrect version check in docker_container
# module, so force downgrade to 1.9.0.
# cf. https://github.com/ansible/ansible/issues/17495
- name: Force docker-py version
pip:
name: docker-py
version: 1.9.0
state: forcereinstall
- name: Restart docker service
service:
name: docker
enabled: true
state: restarted
- name: Start logentries container
docker_container:
name: logentries
image: logentries/docker-logentries
restart: yes
restart_policy: unless-stopped
volumes: '/var/run/docker.sock:/var/run/docker.sock'
command: '-l {{ logentries_logstoken }} -k {{ logentries_statstoken }} -e {{ logentries_eventstoken }} -a host={{ inventory_hostname_short }}'
- name: Start tinyproxy container
docker_container:
name: tinyproxy
image: dannydirect/tinyproxy:latest
restart: yes
restart_policy: unless-stopped
command: '{{ tinyproxy_acl }}'
ports: '8888:8888'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment