open dns to other machines (for allowing pfsense), enable tls for docker registry, add docker_registry to site
This commit is contained in:
parent
0d04d2f038
commit
60a56bdc97
3 changed files with 80 additions and 11 deletions
|
@ -4,5 +4,5 @@
|
||||||
- import_playbook: vault-server.yml
|
- import_playbook: vault-server.yml
|
||||||
- import_playbook: consul-client.yml
|
- import_playbook: consul-client.yml
|
||||||
- import_playbook: nomad.yml
|
- import_playbook: nomad.yml
|
||||||
#- import_playbook: docker-registry.yml
|
- import_playbook: docker-registry.yml
|
||||||
...
|
...
|
||||||
|
|
|
@ -28,6 +28,7 @@ raft_protocol = 3
|
||||||
|
|
||||||
addresses {
|
addresses {
|
||||||
http = "0.0.0.0"
|
http = "0.0.0.0"
|
||||||
|
dns = "0.0.0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
performance {
|
performance {
|
||||||
|
|
|
@ -1,28 +1,96 @@
|
||||||
---
|
---
|
||||||
- name: debug
|
- name: check if server cert is expiring in the next 5 days
|
||||||
debug:
|
shell: "openssl x509 -checkend 432000 -noout -in /etc/pki/certs/docker_registry.crt"
|
||||||
msg: "{{ lookup('hashi_vault', 'secret=pki_int/masked.name') }}"
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
failed_when: False
|
||||||
|
check_mode: False
|
||||||
|
changed_when: False
|
||||||
|
register: exp
|
||||||
|
|
||||||
- name: ensure docker registry dir
|
- name: get cert
|
||||||
file:
|
shell: "vault write pki_int/issue/{{ vault_pki_policy }} common_name=docker.service.{{ main_dc_name }}.{{ consul_domain }} ttl=43200m"
|
||||||
path: "{{ docker_registry_mnt }}"
|
args:
|
||||||
state: directory
|
executable: /bin/bash
|
||||||
|
environment:
|
||||||
|
VAULT_ADDR: http://ivyking.minhas.io:8200
|
||||||
|
VAULT_TOKEN: "{{ lookup('file', lookup('env', 'HOME') + '/.vault-token') }}"
|
||||||
|
VAULT_FORMAT: json
|
||||||
|
register: cert_data
|
||||||
|
when: exp.rc != 0
|
||||||
|
|
||||||
|
- name: write cert data to server
|
||||||
|
copy:
|
||||||
|
content: "{{ item.content }}"
|
||||||
|
dest: "/etc/pki/{{ item.path }}"
|
||||||
|
mode: '{{ item.mode }}'
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0755
|
when: cert_data.changed
|
||||||
|
loop:
|
||||||
|
- {
|
||||||
|
content: "{{ (cert_data.stdout | from_json).data.certificate }}",
|
||||||
|
path: "certs/docker_registry.crt",
|
||||||
|
mode: "0755"
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
content: "{{ (cert_data.stdout | from_json).data.private_key }}",
|
||||||
|
path: "keys/docker_registry.key",
|
||||||
|
mode: "0600"
|
||||||
|
}
|
||||||
- name: ensure python-docker is installed
|
- name: ensure python-docker is installed
|
||||||
apt:
|
apt:
|
||||||
name: python3-docker
|
name: python3-docker
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
|
- name: ensure docker registry ssl dir
|
||||||
|
file:
|
||||||
|
path: /etc/docker_registry/
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: ensure docker registry cert
|
||||||
|
file:
|
||||||
|
state: hard
|
||||||
|
src: /etc/pki/certs/docker_registry.crt
|
||||||
|
dest: /etc/docker_registry/docker_registry.crt
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
|
- name: ensure docker registry private key
|
||||||
|
file:
|
||||||
|
state: hard
|
||||||
|
src: /etc/pki/keys/docker_registry.key
|
||||||
|
dest: /etc/docker_registry/docker_registry.key
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
|
- name: ensure docker registry key and cert are available
|
||||||
|
file:
|
||||||
|
src: "{{ item.src }}"
|
||||||
|
dest: "{{ item.dest }}"
|
||||||
|
state: hard
|
||||||
|
loop:
|
||||||
|
- { src: /etc/pki/certs/docker_registry.crt, dest: /etc/docker_registry/docker_registry.crt }
|
||||||
|
- { src: /etc/pki/keys/docker_registry.key, dest: /etc/docker_registry/docker_registry.key }
|
||||||
|
|
||||||
- name: run docker registry
|
- name: run docker registry
|
||||||
docker_container:
|
docker_container:
|
||||||
name: registry
|
name: registry
|
||||||
image: registry:2
|
image: registry:2
|
||||||
|
env:
|
||||||
|
REGISTRY_HTTP_ADDR: 0.0.0.0:443
|
||||||
|
REGISTRY_HTTP_TLS_CERTIFICATE: /certs/docker_registry.crt
|
||||||
|
REGISTRY_HTTP_TLS_KEY: /certs/docker_registry.key
|
||||||
|
REGISTRY_HTTP_SECRET: "{{ lookup('hashi_vault', 'secret=kv/data/docker:data')['REGISTRY_HTTP_SECRET'] }}"
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "5000:443"
|
||||||
volumes:
|
volumes:
|
||||||
- "{{ docker_registry_mnt }}:/var/lib/registry"
|
- "{{ docker_registry_mnt }}:/var/lib/registry"
|
||||||
|
- "/etc/docker_registry:/certs"
|
||||||
restart_policy: always
|
restart_policy: always
|
||||||
...
|
...
|
||||||
|
|
Loading…
Reference in a new issue