mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
feat(ansible): mirror gitlab repositories fron gitea
This commit is contained in:
@@ -22,6 +22,14 @@ ansible-playbook 'gitlab.yml' --list-tasks
|
|||||||
ansible-playbook 'gitlab.yml' --list-tasks --tags 'configuration,packages'
|
ansible-playbook 'gitlab.yml' --list-tasks --tags 'configuration,packages'
|
||||||
ansible-playbook 'gitlab.yml' --list-tasks --skip-tags 'system,user'
|
ansible-playbook 'gitlab.yml' --list-tasks --skip-tags 'system,user'
|
||||||
|
|
||||||
|
# List installed collections
|
||||||
|
ansible-galaxy collection list
|
||||||
|
|
||||||
|
# Install collections
|
||||||
|
ansible-galaxy collection install 'community.general'
|
||||||
|
ansible-galaxy collection install 'amazon.aws:9.1.0' '/path/to/collection' 'git+file:///path/to/collection.git'
|
||||||
|
ansible-galaxy collection install -r 'requirements.yml'
|
||||||
|
|
||||||
# Create new roles
|
# Create new roles
|
||||||
ansible-galaxy init 'gitlab'
|
ansible-galaxy init 'gitlab'
|
||||||
ansible-galaxy role init 'my_role'
|
ansible-galaxy role init 'my_role'
|
||||||
@@ -106,15 +114,15 @@ diff 'some_role/files/ssh.key.plain' <(ansible-vault view --vault-password-file
|
|||||||
ansible-doc -t 'lookup' -l
|
ansible-doc -t 'lookup' -l
|
||||||
ansible-doc -t 'strategy' -l
|
ansible-doc -t 'strategy' -l
|
||||||
|
|
||||||
# List installed collections
|
|
||||||
ansible-galaxy collection list
|
|
||||||
|
|
||||||
# Show plugin-specific docs and examples
|
# Show plugin-specific docs and examples
|
||||||
ansible-doc -t 'lookup' 'fileglob'
|
ansible-doc -t 'lookup' 'fileglob'
|
||||||
ansible-doc -t 'strategy' 'linear'
|
ansible-doc -t 'strategy' 'linear'
|
||||||
|
|
||||||
# Run commands within Execution Environments
|
# Run commands within Execution Environments
|
||||||
ansible-navigator exec
|
ansible-navigator exec
|
||||||
|
venv/bin/ansible-navigator --mode='stdout' --container-options='--platform=linux/amd64' \
|
||||||
|
--execution-environment-image='012345678901.dkr.ecr.eu-west-1.amazonaws.com/infra/ansible-ee' \
|
||||||
|
exec -- ansible-galaxy collection list
|
||||||
AWS_PROFILE='AnsibleTaskExecutor' venv/bin/ansible-navigator \
|
AWS_PROFILE='AnsibleTaskExecutor' venv/bin/ansible-navigator \
|
||||||
--execution-environment-image='012345678901.dkr.ecr.eu-west-1.amazonaws.com/infra/ansible-ee' \
|
--execution-environment-image='012345678901.dkr.ecr.eu-west-1.amazonaws.com/infra/ansible-ee' \
|
||||||
--execution-environment-volume-mounts="$HOME/.aws:/runner/.aws:ro" \
|
--execution-environment-volume-mounts="$HOME/.aws:/runner/.aws:ro" \
|
||||||
|
|||||||
@@ -848,6 +848,10 @@
|
|||||||
# The datetime format defaults to '%Y-%m-%d %H:%M:%S'.
|
# The datetime format defaults to '%Y-%m-%d %H:%M:%S'.
|
||||||
tags: datetime
|
tags: datetime
|
||||||
block:
|
block:
|
||||||
|
- name: Add or remove time
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
one_year_from_now: "{{ '%Y-%m-%dT%H:%M:%S' | strftime( (ansible_date_time.epoch_int) + (60*60*24*365) ) }}"
|
||||||
|
one_year_from_now_date_only: "{{ '%Y-%m-%d' | strftime( now(fmt='%s')|int + (60*60*24*365) ) }}"
|
||||||
- name: Compare date and times
|
- name: Compare date and times
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
total_seconds_between_dates: >-
|
total_seconds_between_dates: >-
|
||||||
@@ -867,7 +871,7 @@
|
|||||||
date1_short:
|
date1_short:
|
||||||
# Shorten to microseconds
|
# Shorten to microseconds
|
||||||
# Works for any timestamp that has higher than microsecond precision by cutting off anything more precise than that
|
# Works for any timestamp that has higher than microsecond precision by cutting off anything more precise than that
|
||||||
'{{ date1|regex_replace("([^.]+)(\.\d{6})(\d*)(.+)", "\1\2\4") }}'
|
'{{ date1 | regex_replace("([^.]+)(\.\d{6})(\d*)(.+)", "\1\2\4") }}'
|
||||||
iso8601format: '%Y-%m-%dT%H:%M:%S.%fZ'
|
iso8601format: '%Y-%m-%dT%H:%M:%S.%fZ'
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
date_diff_isoed: '{{ (date1_short|to_datetime(iso8601format) - date2|to_datetime(iso8601format)).total_seconds() }}'
|
date_diff_isoed: '{{ (date1_short|to_datetime(iso8601format) - date2|to_datetime(iso8601format)).total_seconds() }}'
|
||||||
@@ -1239,8 +1243,46 @@
|
|||||||
all: true
|
all: true
|
||||||
register: awx_export_output
|
register: awx_export_output
|
||||||
|
|
||||||
|
- name: Gitea-specific operations
|
||||||
|
tags:
|
||||||
|
- gitea
|
||||||
|
- never
|
||||||
|
hosts: localhost
|
||||||
|
connection: local
|
||||||
|
gather_facts: false
|
||||||
|
check_mode: true
|
||||||
|
tasks:
|
||||||
|
- name: Create a GitLab mirror repository in Gitea
|
||||||
|
tags: create_gitea_mirror_gitlab
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: https://gitea.example.org/api/v1/repos/migrate
|
||||||
|
method: POST
|
||||||
|
headers:
|
||||||
|
Authorization: token abcdef0123456789abcdef0123456789abcdef01
|
||||||
|
body_format: json
|
||||||
|
body:
|
||||||
|
auth_username: ro-access
|
||||||
|
auth_token: glpat-projAccesToken012345
|
||||||
|
clone_addr: https://gitlab.example.org/jimmy/secret-project
|
||||||
|
issues: false
|
||||||
|
labels: false
|
||||||
|
lfs: false
|
||||||
|
milestones: false
|
||||||
|
mirror: true
|
||||||
|
mirror_interval: 8h0m0s
|
||||||
|
private: true
|
||||||
|
pull_requests: false
|
||||||
|
releases: false
|
||||||
|
repo_name: secret-project
|
||||||
|
repo_owner: jimmy
|
||||||
|
service: gitlab
|
||||||
|
wiki: false
|
||||||
|
status_code: 201
|
||||||
|
|
||||||
- name: GitLab-specific operations
|
- name: GitLab-specific operations
|
||||||
tags: never
|
tags:
|
||||||
|
- gitlab
|
||||||
|
- never
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
connection: local
|
connection: local
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
@@ -1253,6 +1295,24 @@
|
|||||||
chdir: /root
|
chdir: /root
|
||||||
cmd: gitlab-runner fleeting install
|
cmd: gitlab-runner fleeting install
|
||||||
creates: /root/.config/fleeting/plugins
|
creates: /root/.config/fleeting/plugins
|
||||||
|
- name: Create a Project Access Token for Gitea in GitLab
|
||||||
|
tags: create_gitlab_project_access_token
|
||||||
|
block:
|
||||||
|
- name: Create the access token
|
||||||
|
community.general.gitlab_project_access_token:
|
||||||
|
api_url: https://gitlab.example.org
|
||||||
|
api_token: glpat-m-PLACEHOLDER0123456
|
||||||
|
project: jimmy/secret-project
|
||||||
|
name: ro-access
|
||||||
|
expires_at: "{{ '%Y-%m-%d' | strftime( now(fmt='%s')|int + (60*60*24*365) ) }}" # 1y from now
|
||||||
|
access_level: guest
|
||||||
|
scopes:
|
||||||
|
- read_api
|
||||||
|
- read_repository
|
||||||
|
register: gitlab_project_access_token_creation
|
||||||
|
- name: Save the access token for later use
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
gitlab_project_access_token: "{{ gitlab_project_access_token_creation.access_token.token }}"
|
||||||
|
|
||||||
- name: Let's Encrypt-specific operations
|
- name: Let's Encrypt-specific operations
|
||||||
tags: never
|
tags: never
|
||||||
|
|||||||
@@ -10,3 +10,9 @@ docker exec -ti 'gitea-server-1' sh
|
|||||||
|
|
||||||
# Generate self-signed certificates
|
# Generate self-signed certificates
|
||||||
gitea cert --host 'gitea.lan'
|
gitea cert --host 'gitea.lan'
|
||||||
|
|
||||||
|
# List organizations
|
||||||
|
curl -fsSL -H 'Authorization: token abcdef0123456789abcdef0123456789abcdef01' 'https://gitea.example.org/api/v1/orgs'
|
||||||
|
|
||||||
|
# Get repository information
|
||||||
|
curl -fsSL -H 'Authorization: token a…1' 'https://gitea.example.org/api/v1/repos/john/templates'
|
||||||
|
|||||||
@@ -81,3 +81,5 @@ pg_restore -h 'host.fqdn' -U 'master' -d 'sales' -Oxj '8' 'sales.dump'
|
|||||||
# Initialize a test DB
|
# Initialize a test DB
|
||||||
pgbench -i 'test-db'
|
pgbench -i 'test-db'
|
||||||
pgbench -i 'test-db' -h 'hostname' -p '5555' -U 'user'
|
pgbench -i 'test-db' -h 'hostname' -p '5555' -U 'user'
|
||||||
|
|
||||||
|
pg_isready -U 'denis' -d 'sales'
|
||||||
|
|||||||
Reference in New Issue
Block a user