Skip to content

Commit 8e9fcee

Browse files
author
Bryan Kendall
committed
add reset registry script
1 parent 735f56b commit 8e9fcee

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -e
3+
4+
export DOCK_INIT_BASE="/opt/runnable/dock-init"
5+
export CONSUL_HOSTNAME="{{ consul_hostname }}"
6+
export CONSUL_PORT="8500"
7+
export ORG_ID="$(cat /etc/default/docker | perl -n -e'/org=(\d+)/ && print $1')"
8+
export VAULT_TOKEN="{{ vault_token }}"
9+
10+
REGISTRY_STATUS=$(curl localhost/debug/health)
11+
if [[ "$REGISTRY_STATUS" == "404 page not found" ]]; then
12+
echo "do not need to fix registry"
13+
exit 0
14+
fi
15+
16+
CURRENT_REGISTRY=$(docker ps | awk '/bin\/registry/{ print $1 }')
17+
docker stop -t 5 "$CURRENT_REGISTRY"
18+
docker rm "$CURRENT_REGISTRY"
19+
20+
source "$DOCK_INIT_BASE/lib/container.sh"
21+
22+
echo "starting container"
23+
container::_start_registry_container
24+
25+
sleep 5
26+
27+
echo "checking container"
28+
curl localhost/debug/health
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
- hosts: docks
2+
gather_facts: no
3+
tasks:
4+
- fail: msg="`vault_token` needs to be defined for this role"
5+
when: vault_token is not defined
6+
7+
- fail: msg="`consul_hostname` needs to be defined for this role"
8+
when: consul_hostname is not defined
9+
10+
- name: put script on machine
11+
become: yes
12+
template:
13+
dest: /tmp/reset-registry.sh
14+
src: reset-registry.sh.j2
15+
mode: 0550
16+
17+
- name: run script
18+
become: yes
19+
command: /tmp/reset-registry.sh
20+
21+
- name: remove script
22+
become: yes
23+
command: shred -u /tmp/reset-registry.sh

0 commit comments

Comments
 (0)