File tree Expand file tree Collapse file tree
container_kill_start/tasks Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020[api]
2121beta-api
2222
23- [consul-server ]
23+ [consul]
2424beta-services
2525beta-api
2626beta-web
Original file line number Diff line number Diff line change 11---
22- hosts : consul
3+ serial : 1
34 vars_files :
45 - group_vars/alpha-consul.yml
56 roles :
67 - { role: notify, tags: notify }
78 - { role: database }
8- - { role: container_start , tags: deploy }
9+ - { role: container_kill_start , tags: deploy }
Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ name: consul
33# for database role
44db_path : /etc/consul.d
55
6+ # for container_kill_start
7+ pause_length_minutes : 3
8+
69container_image : progrium/consul
710container_tag : latest
811
Original file line number Diff line number Diff line change 1212 hostname : name="{{inventory_hostname}}--{{ansible_default_ipv4.address|replace(".", "-")}}"
1313 tags : " hostname"
1414
15- - lineinfile :
15+ - name : put hostname in /etc/hosts
16+ lineinfile :
1617 dest=/etc/hosts
1718 regexp="127.0.0.1 {{inventory_hostname}}--{{ansible_default_ipv4.address|replace(".", "-")}}"
1819 line="127.0.0.1 {{inventory_hostname}}--{{ansible_default_ipv4.address|replace(".", "-")}}"
Original file line number Diff line number Diff line change 1010 with_items : stopped_containers.stdout_lines
1111
1212# get current running container with this image
13- - name : look for running containers running {{container_image}}
13+ - name : look for running containers running target image
1414 shell : " sudo docker ps | grep {{container_image}}: | awk '{print $1}'"
1515 register : old_containers_id
1616 changed_when : old_containers_id.stdout != ''
1717
1818# get latest image
1919# tag will default to latest
20- - name : pull down docker image {{container_image}}:{{container_tag}}
20+ - name : pull down target docker image
2121 command : sudo docker pull {{container_image}}:{{container_tag}}
2222 when : not do_not_push
2323
2424# get id of new image
25- - name : get id of the docker image
25+ - name : get id of the target docker image
2626 shell : sudo docker images --no-trunc | grep {{container_image}}.*{{container_tag}} | awk '{print $3}'
2727 register : new_image_id
2828
3838 command : sudo docker rm {{item}}
3939 with_items : old_containers_id.stdout_lines
4040
41+ - name : pause to allow for any odd conditions in system caching tables
42+ when : pause_length_minutes is defined and old_containers_id.changed
43+ pause : minutes={{pause_length_minutes}}
44+
4145# start our new container with options and args
4246- name : start container
4347 command : sudo docker run --log-driver=none -v /var/log:/var/log:rw --restart=always {{container_run_opts}} {{container_image}}:{{container_tag}} {{container_run_args}}
You can’t perform that action at this time.
0 commit comments