From d48316f34d18b0c0992915a17cac5cd50424d4ba Mon Sep 17 00:00:00 2001 From: Sheppy Date: Fri, 29 Dec 2023 14:49:58 +0000 Subject: [PATCH] feat: harbor setup done --- group_vars/harbor-registry.yaml | 4 ++++ .../{templates => files}/harbor-oidc.json | 0 roles/harbor-registry/tasks/main.yaml | 24 +++++++++---------- .../templates/harbor.config.yaml | 4 ++-- 4 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 group_vars/harbor-registry.yaml rename roles/harbor-registry/{templates => files}/harbor-oidc.json (100%) diff --git a/group_vars/harbor-registry.yaml b/group_vars/harbor-registry.yaml new file mode 100644 index 0000000..7dc34f8 --- /dev/null +++ b/group_vars/harbor-registry.yaml @@ -0,0 +1,4 @@ +harbor_version: v2.10.0 +harbor_file: harbor-online-installer-{{ harbor_version }}.tgz +harbor_admin_password: 20Dino00 +harbor_db_password: HISTORY_PURGED_SECRET diff --git a/roles/harbor-registry/templates/harbor-oidc.json b/roles/harbor-registry/files/harbor-oidc.json similarity index 100% rename from roles/harbor-registry/templates/harbor-oidc.json rename to roles/harbor-registry/files/harbor-oidc.json diff --git a/roles/harbor-registry/tasks/main.yaml b/roles/harbor-registry/tasks/main.yaml index f160bed..7015ff4 100644 --- a/roles/harbor-registry/tasks/main.yaml +++ b/roles/harbor-registry/tasks/main.yaml @@ -5,10 +5,6 @@ - docker.io - docker-compose -- set_fact: - harbor_version: v2.10.0 - harbor_file: harbor-online-installer-{{ harbor_version }}.tgz - - name: Create /data/ dir file: path: /data/ @@ -23,24 +19,26 @@ unarchive: remote_src: true src: /opt/harbor-online-installer-v2.10.0.tgz - dest: /opt/harbor/ + dest: /opt/ + register: release - name: Copy harbor config template: src: harbor.config.yaml - dest: /opt/harbor/harbor.yaml + dest: /opt/harbor/harbor.yml # mind the missing a + register: config - name: run installer shell: cmd: ./install.sh chdir: /opt/harbor/ - -- name: Read in OIDC-json - set_fact: - oidc_config_json: "{{ lookup('file','harbor-oidc.json') | from_json }}" + when: config.changed or release.changed + notify: restart harbor - name: Inject OIDC Config - line_in_file: - file: /opt/harbor/common/config/core/env - line: CONFIG_OVERWRITE_JSON={{ oidc_config_json }} + lineinfile: + state: present + path: /opt/harbor/common/config/core/env + line: CONFIG_OVERWRITE_JSON={{ lookup('file','harbor-oidc.json') | from_json | to_json }} + regex: CONFIG_OVERWRITE_JSON= notify: restart harbor diff --git a/roles/harbor-registry/templates/harbor.config.yaml b/roles/harbor-registry/templates/harbor.config.yaml index 056d960..0900492 100644 --- a/roles/harbor-registry/templates/harbor.config.yaml +++ b/roles/harbor-registry/templates/harbor.config.yaml @@ -33,12 +33,12 @@ external_url: https://harbor.atlantishq.de # The initial password of Harbor admin # It only works in first time to install harbor # Remember Change the admin password from UI after launching Harbor. -harbor_admin_password: Harbor12345 +harbor_admin_password: {{ harbor_admin_password }} # Harbor DB configuration database: # The password for the root user of Harbor DB. Change this before any production use. - password: root123 + password: {{ harbor_db_password }} # The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained. max_idle_conns: 100 # The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections.