From f3b788a3e9bcc806e7f7edc1efb66e1672b7692b Mon Sep 17 00:00:00 2001 From: jmgao Date: Thu, 31 May 2018 23:01:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0harbor=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E5=92=8C=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/guide/harbor.md | 8 ++++---- roles/harbor/tasks/main.yml | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/guide/harbor.md b/docs/guide/harbor.md index dae6b7e..0af4cea 100644 --- a/docs/guide/harbor.md +++ b/docs/guide/harbor.md @@ -126,7 +126,7 @@ type: kubernetes.io/dockerconfigjson + 日志目录 `/var/log/harbor` + 数据目录 `/data` ,其中最主要是 `/data/database` 和 `/data/registry` 目录,如果你要彻底重新安装harbor,删除这两个目录即可 -先进入harbor安装目录 `cd /root/local/harbor`,常规操作如下: +先进入harbor安装目录 `cd /opt/harbor`,常规操作如下: 1. 暂停harbor `docker-compose stop` : docker容器stop,并不删除容器 2. 恢复harbor `docker-compose start` : 恢复docker容器运行 @@ -151,7 +151,7 @@ type: kubernetes.io/dockerconfigjson ``` bash # 进入harbor解压缩后的目录,停止harbor -cd /root/local/harbor +cd /opt/harbor docker-compose down # 备份这个目录 @@ -159,7 +159,7 @@ cd .. mkdir -p /backup && mv harbor /backup/harbor # 下载更新的离线安装包,并解压 -tar zxvf harbor-offline-installer-v1.2.2.tgz -C /root/local +tar zxvf harbor-offline-installer-v1.2.2.tgz -C /opt # 使用官方数据库迁移工具,备份数据库,修改数据库连接用户和密码,创建数据库备份目录 # 迁移工具使用docker镜像,镜像tag由待升级到目标harbor版本决定,这里由 1.1.2升级到1.2.2,所以使用 tag 1.2 @@ -171,7 +171,7 @@ docker run -it --rm -e DB_USR=root -e DB_PWD=xxxx -v /data/database:/var/lib/mys docker run -it --rm -e DB_USR=root -e DB_PWD=xxxx -v /data/database:/var/lib/mysql vmware/harbor-db-migrator:1.2 up head # 修改新版本 harbor.cfg配置,需要保持与老版本相关配置项保持一致,然后执行安装即可 -cd /root/local/harbor +cd /opt/harbor vi harbor.cfg ./install.sh diff --git a/roles/harbor/tasks/main.yml b/roles/harbor/tasks/main.yml index 744343e..c1549dd 100644 --- a/roles/harbor/tasks/main.yml +++ b/roles/harbor/tasks/main.yml @@ -12,18 +12,18 @@ - name: 解压harbor离线安装包 unarchive: src: "{{ base_dir }}/down/harbor-offline-installer-v1.2.2.tgz" - dest: /root/local + dest: /opt copy: yes keep_newer: yes - when: result|failed + when: result is failed - name: 导入harbor所需 docker images - shell: "{{ bin_dir }}/docker load -i /root/local/harbor/harbor.v1.2.2.tar.gz" - when: result|failed + shell: "{{ bin_dir }}/docker load -i /opt/harbor/harbor.v1.2.2.tar.gz" + when: result is failed - name: 创建harbor证书请求 template: src=harbor-csr.json.j2 dest={{ ca_dir }}/harbor-csr.json - when: result|failed + when: result is failed - name: 创建harbor证书和私钥 shell: "cd {{ ca_dir }} && {{ bin_dir }}/cfssl gencert \ @@ -31,14 +31,14 @@ -ca-key={{ ca_dir }}/ca-key.pem \ -config={{ ca_dir }}/ca-config.json \ -profile=kubernetes harbor-csr.json | {{ bin_dir }}/cfssljson -bare harbor" - when: result|failed + when: result is failed - name: 配置 harbor.cfg 文件 - template: src=harbor.cfg.j2 dest=/root/local/harbor/harbor.cfg - when: result|failed + template: src=harbor.cfg.j2 dest=/opt/harbor/harbor.cfg + when: result is failed - name: 安装 harbor - shell: "cd /root/local/harbor && \ + shell: "cd /opt/harbor && \ export PATH={{ bin_dir }}:$PATH && \ ./install.sh" - when: result|failed + when: result is failed