initial project commit

This commit is contained in:
Chris Hammer 2023-11-09 15:59:05 -05:00
commit 6bdf47a74b
27 changed files with 513 additions and 0 deletions

105
broken-lint.yml Normal file
View File

@ -0,0 +1,105 @@
---
- name: Deploy Gitea
hosts: gitea
become: true
gather_facts: false
vars:
__gitea_version : 1.20.3
__gitea_arch : amd64
__gitea_binary : "https://dl.gitea.io/gitea/{{ __gitea_version }}/\
gitea-{{ __gitea_version }}-linux-{{ __gitea_arch }}"
__gitea_user:
name : gitea
gecos : Git with a cup of tea
shell : /bin/bash
home : /home/gitea
tasks:
- name: Install Git
ansible.builtin.package:
name : git
state : present
- name: Check if Gitea is present and is correct version
command : /usr/local/bin/gitea --version
ignore_errors : true
changed_when : false
register : r_check_gitea
- name: Gitea presence and version verification
debug :
msg : "Gitea binary not found or version mismatch."
when :
- (r_check_gitea.rc == 1 or r_check_gitea.stdout is not search(__gitea_version))
- name: "Fetch Gitea {{ __gitea_version }}"
ansible.builtin.get_url :
url : "{{ __gitea_binary }}"
dest : /usr/local/bin/gitea
mode : "0755"
notify : Restart Gitea
when :
- (r_check_gitea.rc == 1 or r_check_gitea.stdout is not search(__gitea_version))
- name: Create Gitea user
ansible.builtin.user:
name : "{{__gitea_user.name}}"
comment : "{{ __gitea_user.gecos }}"
shell : "{{ __gitea_user.shell }}"
home : "{{ __gitea_user.home }}"
create_home : true
state : present
- name: Create required directories
ansible.builtin.file:
path : "{{ item }}"
state : directory
recurse : true
owner : "{{ __gitea_user.name }}"
group : "{{ __gitea_user.name }}"
mode : "0750"
loop:
- /var/lib/gitea/custom
- /var/lib/gitea/data
- /var/lib/gitea/log
- /etc/gitea
- name: Deploy unit file for Gitea
ansible.builtin.template:
src : templates/gitea.service.j2
dest : /etc/systemd/system/gitea.service
owner : root
group : root
mode : "0644"
- name: Reload Systemd
ansible.builtin.systemd:
daemon_reload: true
- name: Start Gitea
ansible.builtin.service:
name : gitea
state : started
enabled : true
handlers:
- name: Restart Gitea
ansible.builtin.service:
name : gitea
state : restarted
...

38
roles/bar/README.md Normal file
View File

@ -0,0 +1,38 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@ -0,0 +1,2 @@
---
# defaults file for bar

View File

@ -0,0 +1,2 @@
---
# handlers file for bar

52
roles/bar/meta/main.yml Normal file
View File

@ -0,0 +1,52 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

4
roles/bar/tasks/main.yml Normal file
View File

@ -0,0 +1,4 @@
---
# tasks file for bar
- name: i too cause a lint issue
command: uname -a

View File

@ -0,0 +1,2 @@
localhost

5
roles/bar/tests/test.yml Normal file
View File

@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- bar

2
roles/bar/vars/main.yml Normal file
View File

@ -0,0 +1,2 @@
---
# vars file for bar

38
roles/baz/README.md Normal file
View File

@ -0,0 +1,38 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@ -0,0 +1,2 @@
---
# defaults file for baz

View File

@ -0,0 +1,2 @@
---
# handlers file for baz

52
roles/baz/meta/main.yml Normal file
View File

@ -0,0 +1,52 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

5
roles/baz/tasks/main.yml Normal file
View File

@ -0,0 +1,5 @@
---
# tasks file for baz
- name: im the only decent one among us all
ansible.builtin.debug:
msg: "feed me pizza."

View File

@ -0,0 +1,2 @@
localhost

5
roles/baz/tests/test.yml Normal file
View File

@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- baz

2
roles/baz/vars/main.yml Normal file
View File

@ -0,0 +1,2 @@
---
# vars file for baz

38
roles/foo/README.md Normal file
View File

@ -0,0 +1,38 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@ -0,0 +1,2 @@
---
# defaults file for foo

View File

@ -0,0 +1,2 @@
---
# handlers file for foo

52
roles/foo/meta/main.yml Normal file
View File

@ -0,0 +1,52 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

10
roles/foo/tasks/main.yml Normal file
View File

@ -0,0 +1,10 @@
---
# tasks file for foo
- name: no fqcn for this debug
debug:
msg: "i throw an ansible-lint error."
- name: jijna spacing issue
ansible.builtin.debug:
msg: "{{ansible_play_name}}"

View File

@ -0,0 +1,2 @@
localhost

5
roles/foo/tests/test.yml Normal file
View File

@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- foo

2
roles/foo/vars/main.yml Normal file
View File

@ -0,0 +1,2 @@
---
# vars file for foo

View File

@ -0,0 +1,48 @@
- name: Test Ansible Lint Formatting
hosts: localhost
connection: local
become: false
gather_facts: false
tasks:
- name: Test Ansible Lint - Ignore Errors
# ansible.builtin.command: ansible-lint --nocolor -f json broken-lint.yml
ansible.builtin.command: ansible-lint --nocolor -f json
ignore_errors: true
register: r_lint_output
# - name: Debug r_lint_output
# ansible.builtin.debug:
# var: r_lint_output['stdout']
- name: Capture ansible-lint warnings and errors
ansible.builtin.set_fact:
r_lint_warnings: "{{ r_lint_output['stdout'] | from_json | selectattr('level', 'equalto', 'warning') }}"
r_lint_failures: "{{ r_lint_output['stdout'] | from_json | selectattr('level', 'equalto', 'error') }}"
- name: Debug r_lint_warnings
ansible.builtin.debug:
msg:
- "File: {{ item['location']['path'] }}"
- "Level: {{ item['level'] }}"
- "Severity: {{ item['severity'] }}"
- "Description: {{ item['description'] }}"
loop: "{{ r_lint_warnings }}"
loop_control:
label: "{{ item['location']['path'] }}"
- name: Debug r_lint_failures
ansible.builtin.debug:
msg:
- "File: {{ item['location']['path'] }}"
- "Level: {{ item['level'] }}"
- "Severity: {{ item['severity'] }}"
- "Description: {{ item['description'] }}"
loop: "{{ r_lint_failures }}"
loop_control:
label: "{{ item['location']['path'] }}"

32
test-broken.yml Normal file
View File

@ -0,0 +1,32 @@
- name: Test Ansible Lint Formatting
hosts: localhost
connection: local
become: false
gather_facts: false
tasks:
- name: Test Ansible Lint - Ignore Errors
command: ansible-lint --nocolor -f json broken-lint.yml
ignore_errors: true
register: r_lint_output
- name: Debug r_lint_output
debug:
var: r_lint_output['stdout']
- name: Show something
debug:
msg:
- "Lint Check: {{ item['check_name'] }}"
- "Lint Categories: {{ item['categories'] }}"
- "Lint Description: {{ item['description'] }}"
- "Lint Body: {{ item.content['body'] }}"
- "Lint Location: Line #{{ item['location']['lines']['begin'] }} -> {{ item['location']['path'] }}"
loop: "{{ r_lint_output['stdout'] }}"
loop_control:
label: "{{ item['fingerprint'] }}"