Fixes #11
@ -1,4 +1,3 @@
|
|||||||
# export ANSIBLE_LINT_EXCLUSION="--exclude collections/ansible_collections/ansible* --exclude collections/ansible_collections/community* --exclude .gitea"
|
|
||||||
export ANSIBLE_LINT_EXCLUSION="--exclude collections/ansible_collections --exclude .gitea"
|
export ANSIBLE_LINT_EXCLUSION="--exclude collections/ansible_collections --exclude .gitea"
|
||||||
export ANSIBLE_INVENTORY="-i 127.0.0.1, --connection=local"
|
export ANSIBLE_INVENTORY="-i 127.0.0.1, --connection=local"
|
||||||
export ANSIBLE_PLAYBOOK="gitea.yml"
|
export ANSIBLE_PLAYBOOK="gitea.yml"
|
39
.gitea/workflows/ansible-test.yml
Normal file
39
.gitea/workflows/ansible-test.yml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
name: Ansible Code Pipeline
|
||||||
|
run-name: ${{ gitea.actor }} is running Ansible Code Pipeline
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- testing
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Ansible-Development-Pipeline:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ ansible-dev-centos9, ansible-dev-fedora39, ansible-dev-debian12 ]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Clone repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Ansible Environment Verify
|
||||||
|
run: |
|
||||||
|
whoami
|
||||||
|
. ./.ci.env
|
||||||
|
env
|
||||||
|
git log -1
|
||||||
|
ansible --version
|
||||||
|
ansible-lint --version
|
||||||
|
|
||||||
|
- name: Install Ansible Galaxy Dependencies
|
||||||
|
run: |
|
||||||
|
ansible-galaxy install -r requirements.yml
|
||||||
|
|
||||||
|
- name: Run Ansible-Lint
|
||||||
|
run: |
|
||||||
|
. ./.ci.env
|
||||||
|
ansible-lint --offline $ANSIBLE_LINT_EXCLUSION
|
||||||
|
|
||||||
|
- name: Run Ansible-Playbook
|
||||||
|
run: |
|
||||||
|
. ./.ci.env
|
||||||
|
ansible-playbook -v $ANSIBLE_INVENTORY $ANSIBLE_PLAYBOOK
|
88
gitea.yml
88
gitea.yml
@ -6,90 +6,84 @@
|
|||||||
|
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
__gitea_version : 1.22.5
|
__gitea_version: 1.22.5
|
||||||
__gitea_arch : amd64
|
__gitea_arch: amd64
|
||||||
__gitea_binary : "https://dl.gitea.io/gitea/{{ __gitea_version }}/\
|
__gitea_binary: "https://dl.gitea.io/gitea/{{ __gitea_version }}/\
|
||||||
gitea-{{ __gitea_version }}-linux-{{ __gitea_arch }}"
|
gitea-{{ __gitea_version }}-linux-{{ __gitea_arch }}"
|
||||||
|
|
||||||
__gitea_user:
|
__gitea_user:
|
||||||
name : gitea
|
name: gitea
|
||||||
gecos : Git with a cup of tea
|
gecos: Git with a cup of tea
|
||||||
shell : /bin/bash
|
shell: /bin/bash
|
||||||
home : /home/gitea
|
home: /home/gitea
|
||||||
|
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Install Git
|
- name: Install Git
|
||||||
ansible.builtin.package:
|
ansible.builtin.package:
|
||||||
name : git
|
name: git
|
||||||
state : present
|
state: present
|
||||||
|
|
||||||
|
|
||||||
- name: Check if Gitea is present and is correct version
|
- name: Check if Gitea is present and is correct version
|
||||||
ansible.builtin.command : /usr/local/bin/gitea --version
|
ansible.builtin.command: /usr/local/bin/gitea --version
|
||||||
ignore_errors : true
|
ignore_errors: true
|
||||||
changed_when : false
|
changed_when: false
|
||||||
register : r_check_gitea
|
register: r_check_gitea
|
||||||
|
|
||||||
|
|
||||||
- name: Fetch Gitea binary and notify user
|
- name: Fetch Gitea binary and notify user
|
||||||
when :
|
when :
|
||||||
- (r_check_gitea.rc == 1 or r_check_gitea.stdout is not search(__gitea_version))
|
- (r_check_gitea.rc == 1 or r_check_gitea.stdout is not search(__gitea_version))
|
||||||
block:
|
block:
|
||||||
- name: Gitea binary not found or version mismatch
|
- name: Gitea binary not found or version mismatch
|
||||||
ansible.builtin.debug :
|
ansible.builtin.debug:
|
||||||
msg : "Gitea binary not found or version mismatch."
|
msg: "Gitea binary not found or version mismatch."
|
||||||
|
|
||||||
- name: "Fetch Gitea {{ __gitea_version }}"
|
- name: "Fetch Gitea {{ __gitea_version }}"
|
||||||
ansible.builtin.get_url :
|
ansible.builtin.get_url :
|
||||||
url : "{{ __gitea_binary }}"
|
url: "{{ __gitea_binary }}"
|
||||||
dest : /usr/local/bin/gitea
|
dest: /usr/local/bin/gitea
|
||||||
mode : "0755"
|
mode: "0755"
|
||||||
notify : Restart Gitea
|
notify: Restart Gitea
|
||||||
|
|
||||||
|
|
||||||
- name: Create Gitea user
|
- name: Create Gitea user
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name : "{{ __gitea_user.name }}"
|
name: "{{ __gitea_user.name }}"
|
||||||
comment : "{{ __gitea_user.gecos }}"
|
comment: "{{ __gitea_user.gecos }}"
|
||||||
shell : "{{ __gitea_user.shell }}"
|
shell: "{{ __gitea_user.shell }}"
|
||||||
home : "{{ __gitea_user.home }}"
|
home: "{{ __gitea_user.home }}"
|
||||||
create_home : true
|
create_home: true
|
||||||
state : present
|
state: present
|
||||||
|
|
||||||
|
|
||||||
- name: Create required directories
|
- name: Create required directories
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path : "{{ item }}"
|
path: "{{ item }}"
|
||||||
state : directory
|
state: directory
|
||||||
recurse : true
|
recurse: true
|
||||||
owner : "{{ __gitea_user.name }}"
|
owner: "{{ __gitea_user.name }}"
|
||||||
group : "{{ __gitea_user.name }}"
|
group: "{{ __gitea_user.name }}"
|
||||||
mode : "0750"
|
mode: "0750"
|
||||||
loop:
|
loop:
|
||||||
- /var/lib/gitea/custom
|
- /var/lib/gitea/custom
|
||||||
- /var/lib/gitea/data
|
- /var/lib/gitea/data
|
||||||
- /var/lib/gitea/log
|
- /var/lib/gitea/log
|
||||||
- /etc/gitea
|
- /etc/gitea
|
||||||
|
|
||||||
|
|
||||||
- name: Debug ansible_virtualization_type
|
- name: Debug ansible_virtualization_type
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: ansible_virtualization_type
|
var: ansible_virtualization_type
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
|
|
||||||
- name: Manage Gitea service
|
- name: Manage Gitea service
|
||||||
when:
|
when:
|
||||||
- not ansible_virtualization_type | regex_search('(podman|docker|container)')
|
- not ansible_virtualization_type | regex_search('(podman|docker|container)')
|
||||||
block:
|
block:
|
||||||
- name: Deploy unit file for Gitea
|
- name: Deploy unit file for Gitea
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src : templates/gitea.service.j2
|
src: templates/gitea.service.j2
|
||||||
dest : /etc/systemd/system/gitea.service
|
dest: /etc/systemd/system/gitea.service
|
||||||
owner : root
|
owner: root
|
||||||
group : root
|
group: root
|
||||||
mode : "0644"
|
mode: "0644"
|
||||||
|
|
||||||
- name: Reload Systemd
|
- name: Reload Systemd
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
@ -97,16 +91,16 @@
|
|||||||
|
|
||||||
- name: Start Gitea
|
- name: Start Gitea
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name : gitea
|
name: gitea
|
||||||
state : started
|
state: started
|
||||||
enabled : true
|
enabled: true
|
||||||
|
|
||||||
|
|
||||||
handlers:
|
handlers:
|
||||||
- name: Restart Gitea
|
- name: Restart Gitea
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name : gitea
|
name: gitea
|
||||||
state : restarted
|
state: restarted
|
||||||
when:
|
when:
|
||||||
- not ansible_virtualization_type | regex_search('(podman|docker|container)')
|
- not ansible_virtualization_type | regex_search('(podman|docker|container)')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user