2017-12-25 15:05:21 +08:00
|
|
|
|
- name: 下载docker compose 二进制文件
|
|
|
|
|
copy: src={{ base_dir }}/bin/docker-compose dest={{ bin_dir }}/docker-compose mode=0755
|
|
|
|
|
|
2018-06-08 09:22:43 +08:00
|
|
|
|
- name: 创建data目录
|
|
|
|
|
file:
|
|
|
|
|
path: /data
|
|
|
|
|
state: directory
|
|
|
|
|
mode: 0755
|
|
|
|
|
|
2017-12-25 15:05:21 +08:00
|
|
|
|
# 注册变量result,根据result结果判断是否已经安装过harbor
|
|
|
|
|
# result|failed 说明没有安装过harbor,下一步进行安装
|
|
|
|
|
# result|succeeded 说明已经安装过harbor,下一步跳过安装
|
|
|
|
|
- name: 注册变量result
|
2017-12-25 22:01:44 +08:00
|
|
|
|
command: ls /data/registry
|
2017-12-25 15:05:21 +08:00
|
|
|
|
register: result
|
|
|
|
|
ignore_errors: True
|
|
|
|
|
|
2018-06-08 10:09:03 +08:00
|
|
|
|
- name: 安装解压工具
|
2018-06-28 22:17:16 +08:00
|
|
|
|
package: name={{ item }} state=present
|
2018-06-08 10:09:03 +08:00
|
|
|
|
with_items:
|
|
|
|
|
- zip
|
|
|
|
|
- unzip
|
|
|
|
|
|
2017-12-25 15:05:21 +08:00
|
|
|
|
- name: 解压harbor离线安装包
|
|
|
|
|
unarchive:
|
2018-06-08 09:22:43 +08:00
|
|
|
|
src: "{{ base_dir }}/down/harbor-offline-installer-v1.5.1.zip"
|
|
|
|
|
dest: /data
|
2017-12-25 15:05:21 +08:00
|
|
|
|
copy: yes
|
|
|
|
|
keep_newer: yes
|
2018-08-02 14:24:04 +08:00
|
|
|
|
mode: 0755
|
2018-05-31 23:01:54 +08:00
|
|
|
|
when: result is failed
|
2017-12-25 15:05:21 +08:00
|
|
|
|
|
|
|
|
|
- name: 导入harbor所需 docker images
|
2018-06-08 09:22:43 +08:00
|
|
|
|
shell: "{{ bin_dir }}/docker load -i /data/harbor/harbor.v1.5.1.tar.gz"
|
2018-05-31 23:01:54 +08:00
|
|
|
|
when: result is failed
|
2017-12-25 15:05:21 +08:00
|
|
|
|
|
|
|
|
|
- name: 创建harbor证书请求
|
|
|
|
|
template: src=harbor-csr.json.j2 dest={{ ca_dir }}/harbor-csr.json
|
2018-05-31 23:01:54 +08:00
|
|
|
|
when: result is failed
|
2017-12-25 15:05:21 +08:00
|
|
|
|
|
|
|
|
|
- name: 创建harbor证书和私钥
|
|
|
|
|
shell: "cd {{ ca_dir }} && {{ bin_dir }}/cfssl gencert \
|
|
|
|
|
-ca={{ ca_dir }}/ca.pem \
|
|
|
|
|
-ca-key={{ ca_dir }}/ca-key.pem \
|
|
|
|
|
-config={{ ca_dir }}/ca-config.json \
|
|
|
|
|
-profile=kubernetes harbor-csr.json | {{ bin_dir }}/cfssljson -bare harbor"
|
2018-05-31 23:01:54 +08:00
|
|
|
|
when: result is failed
|
2017-12-25 15:05:21 +08:00
|
|
|
|
|
|
|
|
|
- name: 配置 harbor.cfg 文件
|
2018-06-08 09:22:43 +08:00
|
|
|
|
template: src=harbor.cfg.j2 dest=/data/harbor/harbor.cfg
|
2018-05-31 23:01:54 +08:00
|
|
|
|
when: result is failed
|
2017-12-25 15:05:21 +08:00
|
|
|
|
|
|
|
|
|
- name: 安装 harbor
|
2018-06-08 09:22:43 +08:00
|
|
|
|
shell: "cd /data/harbor && \
|
2017-12-25 15:05:21 +08:00
|
|
|
|
export PATH={{ bin_dir }}:$PATH && \
|
2018-07-04 16:15:21 +08:00
|
|
|
|
./install.sh --with-clair"
|
2018-05-31 23:01:54 +08:00
|
|
|
|
when: result is failed
|