Skip to content

Instantly share code, notes, and snippets.

@pgporada
Last active March 7, 2017 19:53
Show Gist options
  • Save pgporada/195039c72e934901dd61cf92142a9aa3 to your computer and use it in GitHub Desktop.
Save pgporada/195039c72e934901dd61cf92142a9aa3 to your computer and use it in GitHub Desktop.
---
- hosts: localhost
connection: local
tasks:
- name: Install some pip modules
pip:
name: "{{ item }}"
with_items:
- python-consul
- docker-py
- name: Stop old httpd container
docker_container:
name: httpd
state: absent
- name: Deregister old httpd container from consul
consul:
state: absent
service_name: httpd
- name: Start httpd container on ephemeral port
docker_container:
name: httpd
image: httpd
state: started
restart: no
published_ports: "all"
register: dockervar
- debug:
var: dockervar
- name: Get facts about httpd service
docker_image_facts:
name: httpd
- name: Register the new container
consul:
state: present
service_name: httpd
service_port: <=== WHAT GOES HERE? ===>
- name: Register nginx service with the local consul agent
consul:
state: present
service_name: nginx
service_port: 81
scheme: http
http: http://localhost:81
check_name: "Phil's nginx check in consul"
notes: "Please work"
tags:
- Phil
- wuz
- here
interval: 5s
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment