Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clone GitHub repos to the local Gitea during install #212

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d20ba2e
Clone GitHub to the local Gitea during install, in order to avoid Int…
kispaljr Aug 21, 2023
7d0addd
Fix some whitespaces
kispaljr Nov 3, 2023
f304818
Adapting to Victor's changes regarding stock repo handling that happe…
kispaljr Nov 3, 2023
66f93cc
Incorporate changes suggested by Victor
kispaljr Nov 3, 2023
0b4606c
Add missing copyright header
kispaljr Nov 3, 2023
46b398d
Making ansible-lint a bit happier
kispaljr Nov 3, 2023
046db7e
Decrease wait time for creating the new repo in gitea
kispaljr Nov 3, 2023
7397965
Ansible install role: Replace auto-detection of gitea IP by receiving…
kispaljr Nov 3, 2023
5a45916
Make ansible-lint happier
kispaljr Nov 7, 2023
47b6234
Add exceptions for ansible-lint rules wherever it's justified
kispaljr Nov 7, 2023
dfe2649
Ansible: move all Gitea-specific parts out of the install role.
kispaljr Nov 8, 2023
456e465
Fix ansible-lint findings
kispaljr Nov 8, 2023
bae6445
Fix multiline strings
kispaljr Nov 8, 2023
c6f6806
Fix typo
kispaljr Nov 8, 2023
791d7be
Fix idempotency of roles
kispaljr Nov 8, 2023
83019c2
Adjust molecule test of install role
kispaljr Nov 9, 2023
3435afc
Fix ansible-linter findings
kispaljr Nov 9, 2023
9ea5b0a
Fix molecule config
kispaljr Nov 9, 2023
c69df37
Fix install/molecule config
kispaljr Nov 9, 2023
71ab799
Merge remote-tracking branch 'remotes/nokia/github-mirroring' into gi…
kispaljr Nov 9, 2023
9d02ad5
roles/install/molecule test: wait for kind cluster to be ready
kispaljr Nov 9, 2023
2973c15
Fix ansible-lint issue
kispaljr Nov 9, 2023
b90e972
Fix install/molecule test
kispaljr Nov 9, 2023
d3063ef
Fix install/molecule test
kispaljr Nov 10, 2023
85b72b9
Fix install/molecule test
kispaljr Nov 10, 2023
c810d3b
Replace calling kpt CLI with kpt ansible module
kispaljr Nov 10, 2023
73bfec2
ansible-lint
kispaljr Nov 10, 2023
62694fc
Fix install/molecule test
kispaljr Nov 10, 2023
9473f78
Restore creating the Gitea username/password secret also in nephio-sy…
kispaljr Nov 10, 2023
73ca0b4
Fix: Restore creating the Gitea username/password secret also in neph…
kispaljr Nov 10, 2023
747a8a4
debugging install role
kispaljr Nov 10, 2023
9a1564e
debugging install role
kispaljr Nov 10, 2023
4ca8526
Fix molecule test of install role: move setting local git facts from …
kispaljr Nov 10, 2023
5c0461e
Merge nephio/main into github-mirroring to be on the same base as Victor
kispaljr Nov 20, 2023
0123635
Victor's changes
kispaljr Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions e2e/provision/nephio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ all:
gitea_password: secret
validate_certs: true
container_engine: podman
installation_mode: online #online/offline
installation_mode: online # online/offline
proxy:
http_proxy:
http_proxy:
https_proxy:
no_proxy:
host_os: "linux" # use "darwin" for MacOS X, "windows" for Windows
Expand All @@ -28,7 +28,8 @@ all:
tmp_directory: "/tmp"
bin_directory: "/usr/local/bin"
kubectl_version: "1.25.0"
kubectl_checksum_binary: "sha512:fac91d79079672954b9ae9f80b9845fbf373e1c4d3663a84cc1538f89bf70cb85faee1bcd01b6263449f4a2995e7117e1c85ed8e5f137732650e8635b4ecee09"
kubectl_checksum_binary: "sha512:fac91d79079672954b9ae9f80b9845fbf373e1c4d3663a84cc1538f89bf70cb8\
5faee1bcd01b6263449f4a2995e7117e1c85ed8e5f137732650e8635b4ecee09"
kind_version: "0.17.0"
cni_version: "0.8.6"
kpt_version: "1.0.0-beta.31"
Expand Down
6 changes: 4 additions & 2 deletions e2e/provision/playbooks/cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@
block:
- name: Install container lab on Ubuntu family OS
ansible.builtin.apt:
deb: "{{ clab.download_url }}/v{{ clab.version }}/containerlab_{{ clab.version }}_linux_{{ 'amd64' if ansible_architecture == 'x86_64' else ansible_architecture }}.deb"
deb: "{{ clab.download_url }}/v{{ clab.version }}/containerlab_{{ clab.version }}_linux_\
{{ 'amd64' if ansible_architecture == 'x86_64' else ansible_architecture }}.deb"
when: ansible_os_family == 'Debian'
- name: Install container lab on RedHat family OS
ansible.builtin.yum:
name: "{{ clab.download_url }}/v{{ clab.version }}/containerlab_{{ clab.version }}_linux_{{ 'amd64' if ansible_architecture == 'x86_64' else ansible_architecture }}.rpm"
name: "{{ clab.download_url }}/v{{ clab.version }}/containerlab_{{ clab.version }}_linux_\
{{ 'amd64' if ansible_architecture == 'x86_64' else ansible_architecture }}.rpm"
state: present
disable_gpg_check: true
when: ansible_os_family == 'RedHat'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
password: "{{ gitea.k8s.db_password }}"
no_log: true

- name: Create gitea user password
- name: Create gitea user password in Gitea namespace
kubernetes.core.k8s:
context: "{{ k8s.context }}"
state: present
Expand Down
2 changes: 2 additions & 0 deletions e2e/provision/playbooks/roles/install/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ gitea:
k8s:
username: nephio
password: secret
ingress_ip: 172.18.0.200
ingress_port: 3000

nephio_pkg_version: v1.0.1
nephio_example_repo_uri: https://github.com/nephio-project/nephio-example-packages.git
Expand Down
16 changes: 15 additions & 1 deletion e2e/provision/playbooks/roles/install/molecule/ci/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,24 @@ platforms:
provisioner:
name: ansible
playbooks:
prepare: ${MOLECULE_PROJECT_DIRECTORY}/../kpt/molecule/default/prepare.yml
prepare: ${MOLECULE_PROJECT_DIRECTORY}/molecule/default/prepare.yml
converge: ${MOLECULE_PROJECT_DIRECTORY}/molecule/default/converge.yml
env:
ANSIBLE_LIBRARY: ${MOLECULE_PROJECT_DIRECTORY}/../../../playbooks/library
inventory:
group_vars:
all:
k8s:
context: kind-kind
gitea:
k8s:
namespace: gitea
postgres_password: c2VjcmV0 # echo -n "secret" | base64
db_password: c2VjcmV0
username: nephio
password: secret
nephio_pkg_version: v1.0.1
nephio_example_repo_uri: https://github.com/nephio-project/nephio-example-packages.git
verifier:
name: testinfra
directory: ${MOLECULE_PROJECT_DIRECTORY}/molecule/default/tests
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,21 @@ platforms:
gui: false
provisioner:
name: ansible
playbooks:
prepare: ${MOLECULE_PROJECT_DIRECTORY}/../kpt/molecule/default/prepare.yml
env:
ANSIBLE_LIBRARY: ${MOLECULE_PROJECT_DIRECTORY}/../../../playbooks/library
inventory:
group_vars:
all:
k8s:
context: kind-kind
gitea:
k8s:
namespace: gitea
postgres_password: c2VjcmV0 # echo -n "secret" | base64
db_password: c2VjcmV0
username: nephio
password: secret
nephio_pkg_version: v1.0.1
nephio_example_repo_uri: https://github.com/nephio-project/nephio-example-packages.git
verifier:
name: testinfra
57 changes: 57 additions & 0 deletions e2e/provision/playbooks/roles/install/molecule/default/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2023 The Nephio Authors.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

- name: Include the kpt role's prepare playbook
ansible.builtin.import_playbook: ../../../kpt/molecule/default/prepare.yml

- name: Deploy Gitea
hosts: all
pre_tasks:
- name: Update Apt cache
ansible.builtin.raw: apt-get update --allow-releaseinfo-change
become: true
changed_when: false
when: ansible_distribution == 'Ubuntu'
- name: Install pip package
become: true
ansible.builtin.package:
name: python3-pip
state: present
when: ansible_distribution == 'Ubuntu'
- name: Install kubernetes python package
become: true
ansible.builtin.pip:
name: kubernetes==26.1.0
tasks:
- name: Set local git facts
ansible.builtin.include_tasks: ../../../bootstrap/tasks/prep-gitea.yml
- name: Deploy gitea kpt packages
ansible.builtin.include_role:
name: kpt
vars:
repo_uri: "{{ nephio_example_repo_uri }}"
pkg: "{{ item }}"
version: "{{ nephio_pkg_version }}"
context: "{{ k8s.context }}"
kpt_async: 1020
kpt_poll: 5
loop:
- gitea
- metallb
- metallb-sandbox-config
- name: Wait for deployments
ansible.builtin.include_tasks: ../../tasks/wait_deployments.yml
loop_control:
loop_var: namespace
vars:
context: "{{ k8s.context }}"
loop:
- gitea
- metallb-system
30 changes: 6 additions & 24 deletions e2e/provision/playbooks/roles/install/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
vars:
context: "{{ k8s.context }}"

- name: Create gitea user password in nephio-system namespace
- name: Save local git server credentials in nephio-system namespace
kubernetes.core.k8s:
context: "{{ k8s.context }}"
state: present
Expand Down Expand Up @@ -75,39 +75,21 @@
context: "{{ k8s.context }}"
namespace: "{{ nephio_webui.k8s.namespace }}"

- name: Create stock repositories
kubernetes.core.k8s:
state: present
context: "{{ k8s.context }}"
definition:
apiVersion: config.porch.kpt.dev/v1alpha1
kind: Repository
metadata:
name: "{{ item.name }}"
namespace: default
spec:
content: Package
deployment: false
git:
branch: "{{ item.branch }}"
directory: /
repo: "{{ item.repo }}"
type: git
- name: Clone stock GitHub repositories to Gitea
ansible.builtin.include_tasks: mirror_git_repo_to_gitea.yaml
loop: "{{ nephio_stock_repos }}"

- name: Wait for stock repositories
- name: "Wait for stock repository: {{ item.name }}"
kubernetes.core.k8s:
context: "{{ k8s.context }}"
definition:
apiVersion: config.porch.kpt.dev/v1alpha1
kind: Repository
metadata:
name: "{{ item }}"
name: "{{ item.name }}"
namespace: default
wait: true
wait_condition:
type: Ready
status: true
loop:
- nephio-example-packages
- free5gc-packages
loop: "{{ nephio_stock_repos }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2023 The Nephio Authors.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

- name: "Define local git variables"
ansible.builtin.set_fact:
local_git_push_uri: "http://{{ gitea.k8s.username }}:{{ gitea.k8s.password }}@{{ gitea.k8s.ingress_ip }}:{{ gitea.k8s.ingress_port }}/nephio"
local_git_fetch_uri: "http://{{ gitea.k8s.ingress_ip }}:{{ gitea.k8s.ingress_port }}/nephio"
no_log: true

- name: "Create new repo in local git: {{ item.name }}"
kubernetes.core.k8s:
context: "{{ k8s.context }}"
state: present
definition:
apiVersion: infra.nephio.org/v1alpha1
kind: Repository
metadata:
name: "{{ item.name }}"
namespace: default
spec:
description: "Clone of GitHub repository {{ item.name }}"
defaultBranch: main

- name: "Fetch GitHub repo {{ item.name }}"
ansible.builtin.git: # noqa: latest[git]
repo: "{{ item.repo }}"
dest: "/tmp/repository/{{ item.name }}.git"
bare: true

- name: "Add git remote for local repo"
ansible.builtin.command: # noqa: command-instead-of-module
cmd: git remote add local {{ local_git_push_uri }}/{{ item.name }}.git
chdir: "/tmp/repository/{{ item.name }}.git"
register: add_remote_result
changed_when: false
ignore_errors: true
no_log: true

- name: "Push tags to local git repo: {{ item.name }}"
ansible.builtin.command: # noqa: command-instead-of-module
cmd: git push local --tags --force
chdir: /tmp/repository/{{ item.name }}.git
environment:
http_proxy: ""
https_proxy: ""
HTTP_PROXY: ""
HTTPS_PROXY: ""
register: push_result
until: push_result is not failed
retries: 12
delay: 10
changed_when: "'Everything up-to-date' not in push_result.stdout"

- name: "Push branches to local git repo: {{ item.name }}"
ansible.builtin.command: # noqa: command-instead-of-module
cmd: git push local --all --force
chdir: /tmp/repository/{{ item.name }}.git
environment:
http_proxy: ""
https_proxy: ""
HTTP_PROXY: ""
HTTPS_PROXY: ""
register: push_result
changed_when: "'Everything up-to-date' not in push_result.stdout"

- name: "Create porch repository object: {{ item.name }}"
kubernetes.core.k8s:
context: "{{ k8s.context }}"
state: present
definition:
apiVersion: config.porch.kpt.dev/v1alpha1
kind: Repository
metadata:
name: "{{ item.name }}"
namespace: default
labels:
kpt.dev/repository-access: read-only
kpt.dev/repository-content: external-blueprints
spec:
content: Package
deployment: false
git:
branch: "{{ item.branch }}"
directory: /
repo: "{{ local_git_fetch_uri }}/{{ item.name }}.git"
type: git