a16.ansible 生产实战案例 --docker基于镜像仓库安装harbor-https方式 playbook
作者:互联网
1.docker基于镜像仓库 playbook
[root@ansible-server ansible]# mkdir playbook/docker
[root@ansible-server ansible]# cd playbook/docker/
[root@ansible-server docker]# vim files/daemon.json
{
"registry-mirrors": [
"https://hzw5xiv7.mirror.aliyuncs.com",
"https://docker.mirrors.ustc.edu.cn",
"http://f1361db2.m.daocloud.io",
"https://registry.docker-cn.com",
"https://dockerhub.azk8s.cn",
"https://reg-mirror.qiniu.com",
"https://hub-mirror.c.163.com",
"https://mirror.ccs.tencentyun.com"
]
}
[root@ansible-server docker]# vim vars.yml
DOCKER_VERSION: 20.10.11
DOCKER_MIRRORS: mirrors.cloud.tencent.com
[root@ansible-server docker]# vim install_docker.yml
---
- hosts: all
vars_files:
vars.yml
tasks:
- name: add CentOS or Rocky docker mirror warehouse
yum_repository:
name: docker-ce
description: docker-ce
file: docker-ce
baseurl: https://{{ DOCKER_MIRRORS }}/docker-ce/linux/centos/{{ ansible_distribution_major_version }}/x86_64/stable/
gpgkey: https://{{ DOCKER_MIRRORS }}/docker-ce/linux/centos/gpg
gpgcheck: yes
when:
- (ansible_distribution=="CentOS" or ansible_distribution=="Rocky")
- name: install CentOS or Rocky docker
yum:
name: docker-ce-{{ DOCKER_VERSION }},docker-ce-cli-{{ DOCKER_VERSION }}
when:
- (ansible_distribution=="CentOS" or ansible_distribution=="Rocky")
- name: delete lock files
file:
path: "{{ item }}"
state: absent
loop:
- /var/lib/dpkg/lock
- /var/lib/apt/lists/lock
- /var/cache/apt/archives/lock
when:
- ansible_distribution=="Ubuntu"
- name: apt update
apt:
update_cache: yes
force: yes
when:
- ansible_distribution=="Ubuntu"
- name: install Ubuntu docker depend on the package
apt:
name: apt-transport-https,ca-certificates,curl,software-properties-common
force: yes
when:
- ansible_distribution=="Ubuntu"
- name: import Ubuntu docker key
apt_key:
url: https://{{ DOCKER_MIRRORS }}/docker-ce/linux/ubuntu/gpg
when:
- ansible_distribution=="Ubuntu"
- name: import Ubuntu docker installation source
apt_repository:
repo: "deb [arch=amd64] https://{{ DOCKER_MIRRORS }}/docker-ce/linux/ubuntu {{ ansible_distribution_release }} stable"
filename: docker-ce
when:
- ansible_distribution=="Ubuntu"
- name: delete lock files
file:
path: "{{ item }}"
state: absent
loop:
- /var/lib/dpkg/lock
- /var/lib/apt/lists/lock
- /var/cache/apt/archives/lock
when:
- ansible_distribution=="Ubuntu"
- name: apt update
apt:
update_cache: yes
force: yes
when:
- ansible_distribution=="Ubuntu"
- name: install Ubuntu docker
apt:
name: docker-ce=5:{{ DOCKER_VERSION }}~3-0~ubuntu-{{ ansible_distribution_release }},docker-ce-cli=5:{{ DOCKER_VERSION }}~3-0~ubuntu-{{ ansible_distribution_release }}
force: yes
when:
- ansible_distribution=="Ubuntu"
- name: mkdir /etc/docker
file:
path: /etc/docker
state: directory
- name: set mirror_accelerator
copy:
src: daemon.json
dest: /etc/docker/
- name: start docker
systemd:
name: docker
state: started
enabled: yes
daemon_reload: yes
- name: set docker alias
lineinfile:
path: ~/.bashrc
line: "{{ item }}"
loop:
- "alias rmi=\"docker images -qa|xargs docker rmi -f\""
- "alias rmc=\"docker ps -qa|xargs docker rm -f\""
- name: set WARNING No swap limit support
replace:
path: /etc/default/grub
regexp: '^(GRUB_CMDLINE_LINUX=.*)\"$'
replace: '\1 swapaccount=1"'
when:
- ansible_distribution=="Ubuntu"
- name: update-grub
shell:
cmd: update-grub
when:
- ansible_distribution=="Ubuntu"
- name: reboot Ubuntu system
reboot:
when:
- ansible_distribution=="Ubuntu"
[root@ansible-server docker]# cd ../../
[root@ansible-server ansible]# ansible-playbook playbook/docker/install_docker.yml
PLAY [all] ************************************************************************************************************************************
TASK [Gathering Facts] ************************************************************************************************************************
ok: [172.31.0.103]
ok: [172.31.0.105]
ok: [172.31.0.101]
ok: [172.31.0.102]
ok: [172.31.0.104]
TASK [add CentOS or Rocky docker mirror warehouse] ********************************************************************************************
skipping: [172.31.0.104]
skipping: [172.31.0.105]
changed: [172.31.0.103]
changed: [172.31.0.102]
changed: [172.31.0.101]
TASK [install CentOS or Rocky docker] *********************************************************************************************************
skipping: [172.31.0.104]
skipping: [172.31.0.105]
changed: [172.31.0.103]
changed: [172.31.0.102]
changed: [172.31.0.101]
TASK [delete lock files] **********************************************************************************************************************
skipping: [172.31.0.101] => (item=/var/lib/dpkg/lock)
skipping: [172.31.0.101] => (item=/var/lib/apt/lists/lock)
skipping: [172.31.0.102] => (item=/var/lib/dpkg/lock)
skipping: [172.31.0.103] => (item=/var/lib/dpkg/lock)
skipping: [172.31.0.101] => (item=/var/cache/apt/archives/lock)
skipping: [172.31.0.103] => (item=/var/lib/apt/lists/lock)
skipping: [172.31.0.103] => (item=/var/cache/apt/archives/lock)
skipping: [172.31.0.102] => (item=/var/lib/apt/lists/lock)
skipping: [172.31.0.102] => (item=/var/cache/apt/archives/lock)
changed: [172.31.0.104] => (item=/var/lib/dpkg/lock)
changed: [172.31.0.105] => (item=/var/lib/dpkg/lock)
changed: [172.31.0.104] => (item=/var/lib/apt/lists/lock)
changed: [172.31.0.105] => (item=/var/lib/apt/lists/lock)
changed: [172.31.0.104] => (item=/var/cache/apt/archives/lock)
changed: [172.31.0.105] => (item=/var/cache/apt/archives/lock)
TASK [apt update] *****************************************************************************************************************************
skipping: [172.31.0.101]
skipping: [172.31.0.102]
skipping: [172.31.0.103]
changed: [172.31.0.104]
changed: [172.31.0.105]
TASK [install Ubuntu docker depend on the package] ********************************************************************************************
skipping: [172.31.0.101]
skipping: [172.31.0.102]
skipping: [172.31.0.103]
changed: [172.31.0.105]
changed: [172.31.0.104]
TASK [import Ubuntu docker key] ***************************************************************************************************************
skipping: [172.31.0.101]
skipping: [172.31.0.102]
skipping: [172.31.0.103]
changed: [172.31.0.105]
changed: [172.31.0.104]
TASK [import Ubuntu docker installation source] ***********************************************************************************************
skipping: [172.31.0.101]
skipping: [172.31.0.102]
skipping: [172.31.0.103]
changed: [172.31.0.105]
changed: [172.31.0.104]
TASK [delete lock files] **********************************************************************************************************************
skipping: [172.31.0.101] => (item=/var/lib/dpkg/lock)
skipping: [172.31.0.101] => (item=/var/lib/apt/lists/lock)
skipping: [172.31.0.101] => (item=/var/cache/apt/archives/lock)
skipping: [172.31.0.102] => (item=/var/lib/dpkg/lock)
skipping: [172.31.0.102] => (item=/var/lib/apt/lists/lock)
skipping: [172.31.0.102] => (item=/var/cache/apt/archives/lock)
skipping: [172.31.0.103] => (item=/var/lib/dpkg/lock)
skipping: [172.31.0.103] => (item=/var/lib/apt/lists/lock)
skipping: [172.31.0.103] => (item=/var/cache/apt/archives/lock)
changed: [172.31.0.104] => (item=/var/lib/dpkg/lock)
changed: [172.31.0.105] => (item=/var/lib/dpkg/lock)
changed: [172.31.0.105] => (item=/var/lib/apt/lists/lock)
changed: [172.31.0.104] => (item=/var/lib/apt/lists/lock)
changed: [172.31.0.105] => (item=/var/cache/apt/archives/lock)
changed: [172.31.0.104] => (item=/var/cache/apt/archives/lock)
TASK [apt update] *****************************************************************************************************************************
skipping: [172.31.0.101]
skipping: [172.31.0.102]
skipping: [172.31.0.103]
changed: [172.31.0.104]
changed: [172.31.0.105]
TASK [install Ubuntu docker] ******************************************************************************************************************
skipping: [172.31.0.101]
skipping: [172.31.0.102]
skipping: [172.31.0.103]
changed: [172.31.0.104]
changed: [172.31.0.105]
TASK [mkdir /etc/docker] **********************************************************************************************************************
ok: [172.31.0.104]
ok: [172.31.0.105]
changed: [172.31.0.103]
changed: [172.31.0.102]
changed: [172.31.0.101]
TASK [set mirror_accelerator] *****************************************************************************************************************
changed: [172.31.0.103]
changed: [172.31.0.105]
changed: [172.31.0.104]
changed: [172.31.0.102]
changed: [172.31.0.101]
TASK [start docker] ***************************************************************************************************************************
ok: [172.31.0.104]
ok: [172.31.0.105]
changed: [172.31.0.103]
changed: [172.31.0.102]
changed: [172.31.0.101]
TASK [set docker alias] ***********************************************************************************************************************
changed: [172.31.0.103] => (item=alias rmi="docker images -qa|xargs docker rmi -f")
changed: [172.31.0.105] => (item=alias rmi="docker images -qa|xargs docker rmi -f")
changed: [172.31.0.104] => (item=alias rmi="docker images -qa|xargs docker rmi -f")
changed: [172.31.0.102] => (item=alias rmi="docker images -qa|xargs docker rmi -f")
changed: [172.31.0.101] => (item=alias rmi="docker images -qa|xargs docker rmi -f")
changed: [172.31.0.103] => (item=alias rmc="docker ps -qa|xargs docker rm -f")
changed: [172.31.0.105] => (item=alias rmc="docker ps -qa|xargs docker rm -f")
changed: [172.31.0.104] => (item=alias rmc="docker ps -qa|xargs docker rm -f")
changed: [172.31.0.101] => (item=alias rmc="docker ps -qa|xargs docker rm -f")
changed: [172.31.0.102] => (item=alias rmc="docker ps -qa|xargs docker rm -f")
TASK [set WARNING No swap limit support] ******************************************************************************************************
skipping: [172.31.0.101]
skipping: [172.31.0.102]
skipping: [172.31.0.103]
changed: [172.31.0.105]
changed: [172.31.0.104]
TASK [update-grub] ****************************************************************************************************************************
skipping: [172.31.0.101]
skipping: [172.31.0.102]
skipping: [172.31.0.103]
changed: [172.31.0.105]
changed: [172.31.0.104]
TASK [reboot Ubuntu system] *******************************************************************************************************************
skipping: [172.31.0.101]
skipping: [172.31.0.102]
skipping: [172.31.0.103]
changed: [172.31.0.104]
changed: [172.31.0.105]
PLAY RECAP ************************************************************************************************************************************
172.31.0.101 : ok=7 changed=6 unreachable=0 failed=0 skipped=11 rescued=0 ignored=0
172.31.0.102 : ok=7 changed=6 unreachable=0 failed=0 skipped=11 rescued=0 ignored=0
172.31.0.103 : ok=7 changed=6 unreachable=0 failed=0 skipped=11 rescued=0 ignored=0
172.31.0.104 : ok=16 changed=13 unreachable=0 failed=0 skipped=2 rescued=0 ignored=0
172.31.0.105 : ok=16 changed=13 unreachable=0 failed=0 skipped=2 rescued=0 ignored=0
2.docker-compose playbook
[root@ansible-server ansible]# mkdir playbook/docker-compose
[root@ansible-server ansible]# cd playbook/docker-compose/
[root@ansible-server docker-compose]# mkdir files
[root@ansible-server docker-compose]# wget https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64 -P files
[root@ansible-server docker-compose]# vim install_docker_compose.yml
---
- hosts: all
tasks:
- name: copy docker compose file
copy:
src: docker-compose-linux-x86_64
dest: /usr/bin/docker-compose
mode: 755
[root@ansible-server docker-compose]# cd ../../
[root@ansible-server ansible]# ansible-playbook playbook/docker-compose/install_docker_compose.yml
PLAY [all] ************************************************************************************************************************************
TASK [Gathering Facts] ************************************************************************************************************************
ok: [172.31.0.103]
ok: [172.31.0.101]
ok: [172.31.0.104]
ok: [172.31.0.102]
ok: [172.31.0.105]
TASK [copy docker compose file] ***************************************************************************************************************
changed: [172.31.0.103]
changed: [172.31.0.105]
changed: [172.31.0.104]
changed: [172.31.0.102]
changed: [172.31.0.101]
PLAY RECAP ************************************************************************************************************************************
172.31.0.101 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
172.31.0.102 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
172.31.0.103 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
172.31.0.104 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
172.31.0.105 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
[root@rocky8-client ~]# docker-compose --version
docker-compose version 1.29.2, build 5becea4c
[root@centos8-client ~]# docker-compose --version
docker-compose version 1.29.2, build 5becea4c
[root@centos7-client ~]# docker-compose --version
docker-compose version 1.29.2, build 5becea4c
root@ubuntu1804-client:~# docker-compose --version
docker-compose version 1.29.2, build 5becea4c
root@ubuntu2004-client:~# docker-compose --version
docker-compose version 1.29.2, build 5becea4c
3.harbor-https playbook
[root@ansible-server ansible]# mkdir playbook/harbor-https
[root@ansible-server ansible]# cd playbook/harbor-https/
[root@ansible-server harbor-https]# mkdir files
[root@ansible-server harbor-https]# wget https://github.com/goharbor/harbor/releases/download/v2.3.5/harbor-offline-installer-v2.3.5.tgz -P files/
[root@ansible-server harbor-https]# vim vars.yml
HARBOR_INSTALL_DIR: /apps
HARBOR_VERSION: 2.3.5
HARBOR_ADMIN_PASSWORD: 123456
DOMAIN: raymonds.cc
HARBOR_DOMAIN: harbor.raymonds.cc
[root@ansible-server harbor-https]# mkdir templates
[root@ansible-server harbor-https]# vim templates/harbor.servicej2
[Unit]
Description=Harbor
After=docker.service systemd-networkd.service systemd-resolved.service
Requires=docker.service
Documentation=http://github.com/vmware/harbor
[Service]
Type=simple
Restart=on-failure
RestartSec=5
ExecStart=/usr/bin/docker-compose -f {{ HARBOR_INSTALL_DIR }}/harbor/docker-compose.yml up
ExecStop=/usr/bin/docker-compose -f {{ HARBOR_INSTALL_DIR }}/harbor/docker-compose.yml down
[Install]
WantedBy=multi-user.target
[root@ansible-server harbor-https]# vim install_harbor.yml
---
- hosts: all
vars_files:
vars.yml
tasks:
- name: create HARBOR_INSTALL_DIR directory
file:
path: "{{ HARBOR_INSTALL_DIR }}"
state: directory
- name: unarchive harbor package
unarchive:
src: "harbor-offline-installer-v{{ HARBOR_VERSION }}.tgz"
dest: "{{ HARBOR_INSTALL_DIR }}/"
creates: "{{ HARBOR_INSTALL_DIR }}/harbor"
- name: touch file
file:
path: /root/.rnd
state: touch
- name: create certs directory
file:
path: "{{ HARBOR_INSTALL_DIR }}/harbor/certs/"
state: directory
- name: create ca.crt file
shell:
chdir: "{{ HARBOR_INSTALL_DIR }}/harbor/certs/"
cmd: openssl req -newkey rsa:4096 -nodes -sha256 -keyout ca.key -x509 -subj "/CN=ca.{{ DOMAIN }}" -days 365 -out ca.crt
- name: create hostname.csr file
shell:
chdir: "{{ HARBOR_INSTALL_DIR }}/harbor/certs/"
cmd: openssl req -newkey rsa:4096 -nodes -sha256 -subj "/CN={{ HARBOR_DOMAIN }}" -keyout {{ HARBOR_DOMAIN }}.key -out {{ HARBOR_DOMAIN }}.csr
- name: create hostname.csr file
shell:
chdir: "{{ HARBOR_INSTALL_DIR }}/harbor/certs/"
cmd: openssl x509 -req -in {{ HARBOR_DOMAIN }}.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out {{ HARBOR_DOMAIN }}.crt
- name: mv harbor.yml
shell:
cmd: mv {{ HARBOR_INSTALL_DIR }}/harbor/harbor.yml.tmpl {{ HARBOR_INSTALL_DIR }}/harbor/harbor.yml
creates: "{{ HARBOR_INSTALL_DIR }}/harbor/harbor.yml"
- name: set harbor.yml file 'hostname' string line
replace:
path: "{{ HARBOR_INSTALL_DIR }}/harbor/harbor.yml"
regexp: '^(hostname:) .*'
replace: '\1 {{ ansible_default_ipv4.address }}'
- name: set harbor.yml file 'harbor_admin_password' string line
replace:
path: "{{ HARBOR_INSTALL_DIR }}/harbor/harbor.yml"
regexp: '^(harbor_admin_password:) .*'
replace: '\1 {{ HARBOR_ADMIN_PASSWORD }}'
- name: set harbor.yml file 'certificate' string line
replace:
path: "{{ HARBOR_INSTALL_DIR }}/harbor/harbor.yml"
regexp: ' (certificate:) .*'
replace: ' \1 {{ HARBOR_INSTALL_DIR }}/harbor/certs/{{ HARBOR_DOMAIN }}.crt'
- name: set harbor.yml file 'private_key' string line
replace:
path: "{{ HARBOR_INSTALL_DIR }}/harbor/harbor.yml"
regexp: ' (private_key:) .*'
replace: ' \1 {{ HARBOR_INSTALL_DIR }}/harbor/certs/{{ HARBOR_DOMAIN }}.key'
- name: install CentOS or Rocky python
yum:
name: python3
when:
- (ansible_distribution=="CentOS" or ansible_distribution=="Rocky")
- name: delete lock files
file:
path: "{{ item }}"
state: absent
loop:
- /var/lib/dpkg/lock
- /var/lib/apt/lists/lock
- /var/cache/apt/archives/lock
when:
- ansible_distribution=="Ubuntu"
- name: apt update
apt:
update_cache: yes
force: yes
when:
- ansible_distribution=="Ubuntu"
- name: install Ubuntu python
apt:
name: python3
when:
- ansible_distribution=="Ubuntu"
- name: install harbor
shell:
cmd: "{{ HARBOR_INSTALL_DIR }}/harbor/install.sh"
- name: copy harbor.service
template:
src: harbor.service.j2
dest: /lib/systemd/system/harbor.service
- name: service enable
systemd:
name: harbor
state: started
enabled: yes
daemon_reload: yes
[root@ansible-server harbor-https]# cd ../../
[root@ansible-server ansible]# ansible-playbook playbook/harbor-https/install_harbor.yml
PLAY [all] ************************************************************************************************************************************
TASK [Gathering Facts] ************************************************************************************************************************
ok: [172.31.0.103]
ok: [172.31.0.104]
ok: [172.31.0.101]
ok: [172.31.0.105]
ok: [172.31.0.102]
TASK [create HARBOR_INSTALL_DIR directory] ****************************************************************************************************
changed: [172.31.0.103]
changed: [172.31.0.104]
changed: [172.31.0.105]
changed: [172.31.0.101]
changed: [172.31.0.102]
TASK [unarchive harbor package] **************************************************************************************************************
changed: [172.31.0.102]
changed: [172.31.0.103]
changed: [172.31.0.101]
changed: [172.31.0.104]
changed: [172.31.0.105]
TASK [touch file] *****************************************************************************************************************************
changed: [172.31.0.104]
changed: [172.31.0.105]
changed: [172.31.0.103]
changed: [172.31.0.101]
changed: [172.31.0.102]
TASK [create certs directory] *****************************************************************************************************************
changed: [172.31.0.104]
changed: [172.31.0.103]
changed: [172.31.0.105]
changed: [172.31.0.102]
changed: [172.31.0.101]
TASK [create ca.crt file] *********************************************************************************************************************
changed: [172.31.0.105]
changed: [172.31.0.101]
changed: [172.31.0.103]
changed: [172.31.0.104]
changed: [172.31.0.102]
TASK [create hostname.csr file] ***************************************************************************************************************
changed: [172.31.0.101]
changed: [172.31.0.103]
changed: [172.31.0.104]
changed: [172.31.0.105]
changed: [172.31.0.102]
TASK [create hostname.csr file] ***************************************************************************************************************
changed: [172.31.0.103]
changed: [172.31.0.104]
changed: [172.31.0.105]
changed: [172.31.0.101]
changed: [172.31.0.102]
TASK [mv harbor.yml] **************************************************************************************************************************
changed: [172.31.0.104]
changed: [172.31.0.103]
changed: [172.31.0.101]
changed: [172.31.0.105]
changed: [172.31.0.102]
TASK [set harbor.yml file 'hostname' string line] *********************************************************************************************
changed: [172.31.0.104]
changed: [172.31.0.105]
changed: [172.31.0.103]
changed: [172.31.0.102]
changed: [172.31.0.101]
TASK [set harbor.yml file 'harbor_admin_password' string line] ********************************************************************************
changed: [172.31.0.104]
changed: [172.31.0.103]
changed: [172.31.0.105]
changed: [172.31.0.102]
changed: [172.31.0.101]
TASK [set harbor.yml file 'certificate' string line] ******************************************************************************************
changed: [172.31.0.103]
changed: [172.31.0.104]
changed: [172.31.0.105]
changed: [172.31.0.101]
changed: [172.31.0.102]
TASK [set harbor.yml file 'private_key' string line] ******************************************************************************************
changed: [172.31.0.103]
changed: [172.31.0.104]
changed: [172.31.0.105]
changed: [172.31.0.101]
changed: [172.31.0.102]
TASK [install CentOS or Rocky python] *********************************************************************************************************
skipping: [172.31.0.104]
skipping: [172.31.0.105]
changed: [172.31.0.102]
changed: [172.31.0.101]
changed: [172.31.0.103]
TASK [delete lock files] **********************************************************************************************************************
skipping: [172.31.0.101] => (item=/var/lib/dpkg/lock)
skipping: [172.31.0.101] => (item=/var/lib/apt/lists/lock)
skipping: [172.31.0.101] => (item=/var/cache/apt/archives/lock)
skipping: [172.31.0.102] => (item=/var/lib/dpkg/lock)
skipping: [172.31.0.102] => (item=/var/lib/apt/lists/lock)
skipping: [172.31.0.102] => (item=/var/cache/apt/archives/lock)
skipping: [172.31.0.103] => (item=/var/lib/dpkg/lock)
skipping: [172.31.0.103] => (item=/var/lib/apt/lists/lock)
skipping: [172.31.0.103] => (item=/var/cache/apt/archives/lock)
changed: [172.31.0.105] => (item=/var/lib/dpkg/lock)
changed: [172.31.0.104] => (item=/var/lib/dpkg/lock)
changed: [172.31.0.105] => (item=/var/lib/apt/lists/lock)
changed: [172.31.0.104] => (item=/var/lib/apt/lists/lock)
changed: [172.31.0.105] => (item=/var/cache/apt/archives/lock)
changed: [172.31.0.104] => (item=/var/cache/apt/archives/lock)
TASK [apt update] *****************************************************************************************************************************
skipping: [172.31.0.101]
skipping: [172.31.0.102]
skipping: [172.31.0.103]
changed: [172.31.0.104]
changed: [172.31.0.105]
TASK [install Ubuntu python] ******************************************************************************************************************
skipping: [172.31.0.101]
skipping: [172.31.0.102]
skipping: [172.31.0.103]
ok: [172.31.0.105]
ok: [172.31.0.104]
TASK [install harbor] *************************************************************************************************************************
changed: [172.31.0.102]
changed: [172.31.0.101]
changed: [172.31.0.103]
changed: [172.31.0.104]
changed: [172.31.0.105]
TASK [copy harbor.service] ********************************************************************************************************************
changed: [172.31.0.103]
changed: [172.31.0.102]
changed: [172.31.0.101]
changed: [172.31.0.105]
changed: [172.31.0.104]
TASK [service enable] *************************************************************************************************************************
changed: [172.31.0.103]
changed: [172.31.0.104]
changed: [172.31.0.102]
changed: [172.31.0.101]
changed: [172.31.0.105]
PLAY RECAP ************************************************************************************************************************************
172.31.0.101 : ok=17 changed=16 unreachable=0 failed=0 skipped=3 rescued=0 ignored=0
172.31.0.102 : ok=17 changed=16 unreachable=0 failed=0 skipped=3 rescued=0 ignored=0
172.31.0.103 : ok=17 changed=16 unreachable=0 failed=0 skipped=3 rescued=0 ignored=0
172.31.0.104 : ok=19 changed=17 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
172.31.0.105 : ok=19 changed=17 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
[root@rocky8-client ~]# grep "^hostname" /apps/harbor/harbor.yml
hostname: harbor.raymonds.cc
[root@rocky8-client ~]# grep "^harbor_admin_password" /apps/harbor/harbor.yml
harbor_admin_password: 123456
[root@rocky8-client ~]# grep "#http" /apps/harbor/harbor.yml
#http:
[root@rocky8-client ~]# grep "port: 80" /apps/harbor/harbor.yml
# port: 80
[root@rocky8-client ~]# grep "certificate:" /apps/harbor/harbor.yml
certificate: /apps/harbor/certs/harbor.raymonds.cc.crt
[root@rocky8-client ~]# grep "private_key:" /apps/harbor/harbor.yml
private_key: /apps/harbor/certs/harbor.raymonds.cc.key
[root@rocky8-client ~]# ll /apps/harbor/certs/
total 24
-rw-r--r-- 1 root root 1822 Dec 28 17:46 ca.crt
-rw------- 1 root root 3272 Dec 28 17:46 ca.key
-rw-r--r-- 1 root root 41 Dec 28 17:46 ca.srl
-rw-r--r-- 1 root root 1704 Dec 28 17:46 harbor.raymonds.cc.crt
-rw-r--r-- 1 root root 1598 Dec 28 17:46 harbor.raymonds.cc.csr
-rw------- 1 root root 3272 Dec 28 17:46 harbor.raymonds.cc.key
[root@rocky8-client ~]# systemctl status harbor
● harbor.service - Harbor
Loaded: loaded (/usr/lib/systemd/system/harbor.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2021-12-28 17:47:44 CST; 2min 9s ago
Docs: http://github.com/vmware/harbor
Main PID: 6869 (docker-compose)
Tasks: 12 (limit: 4783)
Memory: 55.7M
CGroup: /system.slice/harbor.service
├─6869 /usr/bin/docker-compose -f /apps/harbor/docker-compose.yml up
└─6886 /usr/bin/docker-compose -f /apps/harbor/docker-compose.yml up
Dec 28 17:49:32 rocky8-client.example.local docker-compose[6869]: harbor-portal | 172.18.0.8 - - [28/Dec/2021:09:49:32 +0000] "GET / HTTP/1.1>
Dec 28 17:49:32 rocky8-client.example.local docker-compose[6869]: registry | 172.18.0.8 - - [28/Dec/2021:09:49:32 +0000] "GET / HTTP/1.1>
Dec 28 17:49:32 rocky8-client.example.local docker-compose[6869]: registryctl | 172.18.0.8 - - [28/Dec/2021:09:49:32 +0000] "GET /api/healt>
Dec 28 17:49:33 rocky8-client.example.local docker-compose[6869]: nginx | 127.0.0.1 - "GET / HTTP/1.1" 308 171 "-" "curl/7.78.0" 0.00>
Dec 28 17:49:42 rocky8-client.example.local docker-compose[6869]: registry | 172.18.0.8 - - [28/Dec/2021:09:49:42 +0000] "GET / HTTP/1.1>
Dec 28 17:49:42 rocky8-client.example.local docker-compose[6869]: harbor-portal | 172.18.0.8 - - [28/Dec/2021:09:49:42 +0000] "GET / HTTP/1.1>
Dec 28 17:49:42 rocky8-client.example.local docker-compose[6869]: registryctl | 172.18.0.8 - - [28/Dec/2021:09:49:42 +0000] "GET /api/healt>
Dec 28 17:49:52 rocky8-client.example.local docker-compose[6869]: harbor-portal | 172.18.0.8 - - [28/Dec/2021:09:49:52 +0000] "GET / HTTP/1.1>
Dec 28 17:49:52 rocky8-client.example.local docker-compose[6869]: registry | 172.18.0.8 - - [28/Dec/2021:09:49:52 +0000] "GET / HTTP/1.1>
Dec 28 17:49:52 rocky8-client.example.local docker-compose[6869]: registryctl | 172.18.0.8 - - [28/Dec/2021:09:49:52 +0000] "GET /api/healt>
#在windows系统“C:\Windows\System32\drivers\etc\hosts”文件里添加下面内容
172.31.0.101 harbor.raymonds.cc
标签:a16,skipping,harbor,changed,--,ansible,172.31,docker 来源: https://blog.csdn.net/qq_25599925/article/details/122199958