Skip to content

Commit

Permalink
简化ansible hosts中 harbor变量配置
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmzj committed Aug 23, 2018
1 parent 0036c62 commit c911d2f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 24 deletions.
10 changes: 6 additions & 4 deletions 11.harbor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@
- new-master
- kube-node
- new-node
vars:
harbor_domain: "{{ hostvars[groups.harbor[0]]['HARBOR_DOMAIN'] }}"
tasks:
- name: harbor证书目录创建
file: name=/etc/docker/certs.d/{{ HARBOR_DOMAIN }} state=directory
file: name=/etc/docker/certs.d/{{ harbor_domain }} state=directory

- name: harbor服务器证书安装
copy: src={{ ca_dir }}/ca.pem dest=/etc/docker/certs.d/{{ HARBOR_DOMAIN }}/ca.crt
copy: src={{ ca_dir }}/ca.pem dest=/etc/docker/certs.d/{{ harbor_domain }}/ca.crt

# 如果你的环境中有dns服务器,可以跳过hosts文件设置
- name: 增加harbor的hosts解析
lineinfile:
dest: /etc/hosts
state: present
regexp: '{{ HARBOR_DOMAIN }}'
line: '{{ HARBOR_IP }} {{ HARBOR_DOMAIN }}'
regexp: '{{ harbor_domain }}'
line: "{{ groups['harbor'][0] }} {{ harbor_domain }}"
6 changes: 1 addition & 5 deletions docs/guide/harbor.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ mv docker-compose-Linux-x86_64 /etc/ansible/bin/docker-compose
``` bash
# 如果启用harbor,请配置后面harbor相关参数
[harbor]
192.168.1.8

#私有仓库 harbor服务器 (域名或者IP)
HARBOR_IP="192.168.1.8"
HARBOR_DOMAIN="harbor.test.com"
192.168.1.8 HARBOR_DOMAIN="harbor.yourdomain.com"
```

4. 在deploy节点执行 `cd /etc/ansible && ansible-playbook 11.harbor.yml`,完成harbor安装
Expand Down
6 changes: 1 addition & 5 deletions example/hosts.allinone.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# 如果启用harbor,请配置后面harbor相关参数
[harbor]
#192.168.1.8
#192.168.1.8 HARBOR_DOMAIN="harbor.yourdomain.com"

# 预留组,后续添加node节点使用
[new-node]
Expand Down Expand Up @@ -70,7 +70,3 @@ ca_dir="/etc/kubernetes/ssl"

#部署目录,即 ansible 工作目录
base_dir="/etc/ansible"

#私有仓库 harbor服务器 (域名或者IP)
#HARBOR_IP="192.168.1.8"
#HARBOR_DOMAIN="harbor.yourdomain.com"
6 changes: 1 addition & 5 deletions example/hosts.m-masters.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# 如果启用harbor,请配置后面harbor相关参数
[harbor]
#192.168.1.8
#192.168.1.8 HARBOR_DOMAIN="harbor.yourdomain.com"

# 预留组,后续添加master节点使用
[new-master]
Expand Down Expand Up @@ -84,7 +84,3 @@ ca_dir="/etc/kubernetes/ssl"

#部署目录,即 ansible 工作目录,建议不要修改
base_dir="/etc/ansible"

#私有仓库 harbor服务器 (域名或者IP)
#HARBOR_IP="192.168.1.8"
#HARBOR_DOMAIN="harbor.yourdomain.com"
6 changes: 1 addition & 5 deletions example/hosts.s-master.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# 如果启用harbor,请配置后面harbor相关参数
[harbor]
#192.168.1.8
#192.168.1.8 HARBOR_DOMAIN="harbor.yourdomain.com"

# 预留组,后续添加node节点使用
[new-node]
Expand Down Expand Up @@ -71,7 +71,3 @@ ca_dir="/etc/kubernetes/ssl"

#部署目录,即 ansible 工作目录
base_dir="/etc/ansible"

#私有仓库 harbor服务器 (域名或者IP)
#HARBOR_IP="192.168.1.8"
#HARBOR_DOMAIN="harbor.yourdomain.com"

0 comments on commit c911d2f

Please sign in to comment.