commit 6bdf47a74b9a51c69329a27e1ccac8b45a225b3d Author: Chris Hammer Date: Thu Nov 9 15:59:05 2023 -0500 initial project commit diff --git a/broken-lint.yml b/broken-lint.yml new file mode 100644 index 0000000..8bff036 --- /dev/null +++ b/broken-lint.yml @@ -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 + + +... diff --git a/roles/bar/README.md b/roles/bar/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/bar/README.md @@ -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). diff --git a/roles/bar/defaults/main.yml b/roles/bar/defaults/main.yml new file mode 100644 index 0000000..154f4c6 --- /dev/null +++ b/roles/bar/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for bar diff --git a/roles/bar/handlers/main.yml b/roles/bar/handlers/main.yml new file mode 100644 index 0000000..37a5ba9 --- /dev/null +++ b/roles/bar/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for bar diff --git a/roles/bar/meta/main.yml b/roles/bar/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/bar/meta/main.yml @@ -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. diff --git a/roles/bar/tasks/main.yml b/roles/bar/tasks/main.yml new file mode 100644 index 0000000..8dacf06 --- /dev/null +++ b/roles/bar/tasks/main.yml @@ -0,0 +1,4 @@ +--- +# tasks file for bar +- name: i too cause a lint issue + command: uname -a diff --git a/roles/bar/tests/inventory b/roles/bar/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/bar/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/bar/tests/test.yml b/roles/bar/tests/test.yml new file mode 100644 index 0000000..0c61761 --- /dev/null +++ b/roles/bar/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - bar diff --git a/roles/bar/vars/main.yml b/roles/bar/vars/main.yml new file mode 100644 index 0000000..aa40a3b --- /dev/null +++ b/roles/bar/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for bar diff --git a/roles/baz/README.md b/roles/baz/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/baz/README.md @@ -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). diff --git a/roles/baz/defaults/main.yml b/roles/baz/defaults/main.yml new file mode 100644 index 0000000..edb11d3 --- /dev/null +++ b/roles/baz/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for baz diff --git a/roles/baz/handlers/main.yml b/roles/baz/handlers/main.yml new file mode 100644 index 0000000..31ec66a --- /dev/null +++ b/roles/baz/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for baz diff --git a/roles/baz/meta/main.yml b/roles/baz/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/baz/meta/main.yml @@ -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. diff --git a/roles/baz/tasks/main.yml b/roles/baz/tasks/main.yml new file mode 100644 index 0000000..895d334 --- /dev/null +++ b/roles/baz/tasks/main.yml @@ -0,0 +1,5 @@ +--- +# tasks file for baz +- name: im the only decent one among us all + ansible.builtin.debug: + msg: "feed me pizza." diff --git a/roles/baz/tests/inventory b/roles/baz/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/baz/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/baz/tests/test.yml b/roles/baz/tests/test.yml new file mode 100644 index 0000000..7e4785a --- /dev/null +++ b/roles/baz/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - baz diff --git a/roles/baz/vars/main.yml b/roles/baz/vars/main.yml new file mode 100644 index 0000000..adcd99b --- /dev/null +++ b/roles/baz/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for baz diff --git a/roles/foo/README.md b/roles/foo/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/foo/README.md @@ -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). diff --git a/roles/foo/defaults/main.yml b/roles/foo/defaults/main.yml new file mode 100644 index 0000000..5aa0c23 --- /dev/null +++ b/roles/foo/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for foo diff --git a/roles/foo/handlers/main.yml b/roles/foo/handlers/main.yml new file mode 100644 index 0000000..a7fb1b8 --- /dev/null +++ b/roles/foo/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for foo diff --git a/roles/foo/meta/main.yml b/roles/foo/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/foo/meta/main.yml @@ -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. diff --git a/roles/foo/tasks/main.yml b/roles/foo/tasks/main.yml new file mode 100644 index 0000000..b45d519 --- /dev/null +++ b/roles/foo/tasks/main.yml @@ -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}}" diff --git a/roles/foo/tests/inventory b/roles/foo/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/foo/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/foo/tests/test.yml b/roles/foo/tests/test.yml new file mode 100644 index 0000000..a9e819a --- /dev/null +++ b/roles/foo/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - foo diff --git a/roles/foo/vars/main.yml b/roles/foo/vars/main.yml new file mode 100644 index 0000000..8e24288 --- /dev/null +++ b/roles/foo/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for foo diff --git a/test-broken-selectattr.yml b/test-broken-selectattr.yml new file mode 100644 index 0000000..ae874f6 --- /dev/null +++ b/test-broken-selectattr.yml @@ -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'] }}" diff --git a/test-broken.yml b/test-broken.yml new file mode 100644 index 0000000..2ebcfdc --- /dev/null +++ b/test-broken.yml @@ -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'] }}" + +