Use ansible.builtin and add new adhocs

This commit is contained in:
nazunalika 2022-03-27 17:53:47 -07:00
parent 775c389c45
commit 375f217ba2
Signed by: label
GPG Key ID: 6735C0E1BD65D048
7 changed files with 113 additions and 33 deletions

View File

@ -1,7 +1,10 @@
--- ---
# This playbook is meant to be used with callable variables, like adhoc or AWX. # This playbook is meant to be used with callable variables, like adhoc or AWX.
# What: Creates an organization/group in Gitea, relying on the gitea collection # What: Creates an organization/group in Gitea, relying on the gitea collection
# What is expected: # What is expected (at a minimum):
# -> gitea_api_user + gitea_api_password *OR* gitea_api_token
# -> gitea_org_name
# -> gitea_org_owner, optional (defaults to token or api user if not set)
- name: Create Gitea Organization or Group - name: Create Gitea Organization or Group
hosts: all hosts: all
become: false become: false
@ -12,4 +15,16 @@
# Optionally assign user as part of owner team # Optionally assign user as part of owner team
# Remove automated account # Remove automated account
tasks: tasks:
- name: "Create organization"
lazyutilitynet.ansible_gitea.gitea_org:
api_url: "https://{{ gitea_basename }}"
api_username: "{{ gitea_api_user|default(omit) }}"
api_password: "{{ gitea_api_password|default(omit) }}"
api_token: "{{ gitea_api_token|default(omit) }}"
state: "{{ gitea_org_state|default('present') }}"
org_name: "{{ gitea_org_name }}"
location: "{{ gitea_org_location|default(omit) }}"
full_name: "{{ gitea_org_full_name|default(omit) }}"
owner: "{{ gitea_org_owner|default(omit) }}"
description: "{{ gitea_org_desc|default(omit) }}"
... ...

34
adhoc-create-team.yml Normal file
View File

@ -0,0 +1,34 @@
---
# This playbook is meant to be used with callable variables, like adhoc or AWX.
# What: Creates an team in a Gitea Organization, relying on the gitea collection
# What is expected:
# -> gitea_api_user + gitea_api_password *OR* gitea_api_token
# -> gitea_org_name
# -> gitea_team_name
# -> gitea_state, present or absent (defaults to present)
# -> gitea_permission, none/read/write/admin (default read)
# -> gitea_permissions, this is a dictionary, cannot be paired with
# gitea_permission
- name: Create Gitea Team in an Organization or Group
hosts: all
become: false
vars_files:
- "vars/common.yml"
# Create team
tasks:
- name: "Create team and Add Users"
lazyutilitynet.ansible_gitea.gitea_team:
api_url: "https://{{ gitea_basename }}"
api_username: "{{ gitea_api_user|default(omit) }}"
api_password: "{{ gitea_api_password|default(omit) }}"
api_token: "{{ gitea_api_token|default(omit) }}"
state: "{{ gitea_org_state|default('present') }}"
org_name: "{{ gitea_org_name }}"
name: "{{ gitea_team_name }}"
description: "{{ gitea_org_desc|default(omit) }}"
members: "{{ gitea_team_members|default(omit) }}"
permission: "{{ gitea_permission|default(omit) }}"
permissions: "{{ gitea_permissions|default(omit) }}"
member_action: "add"
...

View File

@ -0,0 +1,28 @@
---
# This playbook is meant to be used with callable variables, like adhoc or AWX.
# What: Modifies a team in a Gitea Organization, relying on the gitea collection
# What is expected:
# -> gitea_api_user + gitea_api_password *OR* gitea_api_token
# -> gitea_org_name
# -> gitea_team_name
# -> gitea_team_members (in the form of a list)
# -> gitea_team_action, add or remove
- name: Create Gitea Team in an Organization or Group
hosts: all
become: false
vars_files:
- "vars/common.yml"
# Create team
tasks:
- name: "Create team and Add Users"
lazyutilitynet.ansible_gitea.gitea_team:
api_url: "https://{{ gitea_basename }}"
api_username: "{{ gitea_api_user|default(omit) }}"
api_password: "{{ gitea_api_password|default(omit) }}"
api_token: "{{ gitea_api_token|default(omit) }}"
org_name: "{{ gitea_org_name }}"
name: "{{ gitea_team_name }}"
members: "{{ gitea_team_members }}"
member_action: "{{ gitea_team_action }}"
...

View File

@ -21,12 +21,15 @@
success_msg: "We are able to run on this node" success_msg: "We are able to run on this node"
fail_msg: "/etc/no-ansible exists - skipping run on this node" fail_msg: "/etc/no-ansible exists - skipping run on this node"
- name: Enable the proper copr for gitea # name: Enable the proper copr for gitea
command: "dnf copr enable nalika/gitea -y" # command: "dnf copr enable nalika/gitea -y"
check_mode: false # check_mode: false
changed_when: "1 != 1" # changed_when: "1 != 1"
roles: roles:
- role: lazyutilitynet.ansible_gitea.gitea_install
state: present
- role: rockylinux.ipagetcert - role: rockylinux.ipagetcert
state: present state: present
when: gitea_web_config_certs_internal|bool when: gitea_web_config_certs_internal|bool

View File

@ -1,7 +1,7 @@
--- ---
# Configuration for gitea # Configuration for gitea
- name: Enable Gitea - name: Enable Gitea
service: ansible.builtin.service:
name: gitea name: gitea
state: started state: started
enabled: true enabled: true

View File

@ -1,38 +1,38 @@
--- ---
# Install gitea # Install gitea
- name: "Installing Gitea from COPR" # name: "Installing Gitea from COPR"
dnf: # dnf:
name: gitea # name: gitea
state: present # state: present
# Install web front end # Install web front end
- name: "Installing httpd package and configuration" # name: "Installing httpd package and configuration"
dnf: # dnf:
name: gitea-httpd # name: gitea-httpd
state: present # state: present
when: # when:
- gitea_web_install == "httpd" # - gitea_web_install == "httpd"
- gitea_web_config|bool # - gitea_web_config|bool
- name: "Installing nginx package and configuration" # name: "Installing nginx package and configuration"
dnf: # dnf:
name: gitea-nginx # name: gitea-nginx
state: present # state: present
when: # when:
- gitea_web_install == "nginx" # - gitea_web_install == "nginx"
- gitea_web_config|bool # - gitea_web_config|bool
- name: "Installing caddy package and configuration" # name: "Installing caddy package and configuration"
dnf: # dnf:
name: gitea-caddy # name: gitea-caddy
state: present # state: present
when: # when:
- gitea_web_install == "caddy" # - gitea_web_install == "caddy"
- gitea_web_config|bool # - gitea_web_config|bool
# Setup CSS Themes # Setup CSS Themes
- name: - name:
file: ansible.builtin.file:
path: "/var/lib/gitea/custom/public/css" path: "/var/lib/gitea/custom/public/css"
owner: git owner: git
group: git group: git

View File

@ -1,6 +1,6 @@
--- ---
- name: Deploy all theme files - name: Deploy all theme files
copy: ansible.builtin.copy:
src: "var/lib/gitea/custom/public/css/{{ item }}" src: "var/lib/gitea/custom/public/css/{{ item }}"
dest: "/var/lib/gitea/custom/public/css/{{ item }}" dest: "/var/lib/gitea/custom/public/css/{{ item }}"
mode: '0644' mode: '0644'