Skip to content

Commit 3a2e970

Browse files
Merge pull request #443 from CodeNow/reset-registry.yml
Reset Registry Keys
2 parents 11b2c49 + 5a3ee3a commit 3a2e970

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)