Skip to content

Commit 86e6adc

Browse files
committed
feat(ansible): Ansible modules added.
1 parent dbc71eb commit 86e6adc

107 files changed

Lines changed: 2708 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/jekyll/ansible-docs/ansible-autodoc.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,36 @@ parent: jcook3701.homelab
2121
* `infrastructure` -
2222

2323

24+
* `{{ autobuild.git_repo.tags }}` -
25+
26+
27+
* `server` -
28+
29+
30+
* `update-workstations` -
31+
32+
33+
* `backup-workstations` -
34+
35+
36+
* `backup-nas` -
37+
38+
39+
* `create-cron` -
40+
41+
42+
* `remove-cron` -
43+
44+
45+
* `workstation` -
46+
47+
48+
* `clear-logs` -
49+
50+
51+
* `debug` -
52+
53+
2454

2555
Documentation generated using: [Ansible-autodoc](https://github.com/AndresBott/ansible-autodoc)
2656

roles/autobuild/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Autobuild

roles/autobuild/meta/main.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SPDX-FileCopyrightText: Copyright © 2026, Jared Cook
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
---
4+
galaxy_info:
5+
author: Jared Cook
6+
description: ""
7+
# company: "Optional Company Name"
8+
9+
license: "AGPL-3.0-or-later"
10+
11+
min_ansible_version: ">=2.10"
12+
role_name: autobuild
13+
14+
platforms:
15+
- name: EL
16+
versions:
17+
- "8"
18+
- "9"
19+
- name: Debian
20+
versions:
21+
- all
22+
- name: Ubuntu
23+
versions:
24+
- all
25+
26+
galaxy_tags:
27+
- homelab
28+
- desktop
29+
- server
30+
- apps
31+
32+
dependencies: []
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# SPDX-FileCopyrightText: Copyright © 2026, Jared Cook
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
---
4+
# Subroutine of pkg-source-build-init-routine
5+
# Purpose is to initialize all variables required to install a specific
6+
# package from source code.
7+
8+
- name: Initialize autobuild variable
9+
block:
10+
- name: Create autobuild variable.
11+
ansible.builtin.set_fact:
12+
autobuild: null
13+
14+
- name: Set the local 'git_repo' variable within the autobuild variable
15+
ansible.builtin.set_fact:
16+
autobuild:
17+
git_repo: "{{ git_repo }}"
18+
when: git_repo is defined
19+
20+
- name: Set the local 'build' variable within the autobuild variable
21+
ansible.builtin.set_fact:
22+
autobuild: >-
23+
{{ autobuild
24+
| combine({'build': build})
25+
}}
26+
when: build is defined
27+
28+
# NOTE: This is commented because bashrc vars are being moved to build
29+
# - name: set the local 'bashrc' variable within the autobuild variable
30+
# ansible.builtin.set_fact:
31+
# autobuild: >-
32+
# {{ autobuild | combine({'bashrc': bashrc }) }}
33+
# when: bashrc is defined
34+
35+
- name: Set the local 'pkgs' variable within the autobuild variable
36+
ansible.builtin.set_fact:
37+
autobuild: >-
38+
{{ autobuild
39+
| combine({'pkgs': pkgs})
40+
}}
41+
when: pkgs is defined
42+
43+
- name: Display Autobuild Variable after initialization
44+
ansible.builtin.debug:
45+
msg: "{{ autobuild }}"
46+
when: autobuild is defined
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# SPDX-FileCopyrightText: Copyright © 2026, Jared Cook
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
---
4+
- name: Collect running user facts
5+
when: sudo_user is not defined
6+
ansible.builtin.include_tasks: utilities/sudo_user_facts.yml
7+
8+
# TODO: When autobuild.build.prefix need to update autobuild.bashrc.marker to include install path
9+
10+
- name: Initialize bashrc variables
11+
block:
12+
- name: set base bashrc export type fact
13+
when: autobuild.build.type is defined
14+
ansible.builtin.set_fact:
15+
bashrc_export: >-
16+
{{ bash_export_types[autobuild.build.type] }}
17+
18+
- name: set bashrc block for lib or bin prefix
19+
when: bashrc_export is defined
20+
ansible.builtin.set_fact:
21+
bashrc_block: >-
22+
{{ ['export', ' ', bashrc_export, '=', autobuild.build.full_install_path, '$', bashrc_export]
23+
| join('')
24+
}}
25+
26+
- name: set base bashrc facts
27+
ansible.builtin.set_fact:
28+
bashrc:
29+
name: "{{ autobuild.git_repo.name }}"
30+
marker: "# {mark} Ansible - {{ autobuild.git_repo.name }}"
31+
block: "{{ lookup('template', 'utilities/bashrc-block.j2') }}"
32+
33+
- name: View .bashrc settings
34+
ansible.builtin.debug:
35+
msg: >-
36+
{{ bashrc }}
37+
38+
- name: Set bashrc block build with prefix defined
39+
ansible.builtin.set_fact:
40+
autobuild: >-
41+
{{ autobuild
42+
| combine({'bashrc': bashrc })
43+
}}
44+
45+
# when: autobuild.build.bashrc is not defined and autobuild.build.prefix is defined
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# SPDX-FileCopyrightText: Copyright © 2026, Jared Cook
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
# Subroutine of pkg-source-build-routine
5+
6+
# @param item?: {raw_tag: string, project: string, major: string, minor: string, patch: string}
7+
---
8+
- name: Collect running user facts
9+
ansible.builtin.include_tasks: utilities/sudo_user_facts.yml
10+
when: sudo_user is not defined
11+
12+
- name: Initialize checkinstall variables
13+
when: item is defined and autobuild is defined
14+
block:
15+
- name: Package Version
16+
ansible.builtin.set_fact:
17+
pkgversion: >-
18+
{{ [item.major, item.minor, item.patch] | select('defined') | join('.') }}
19+
20+
- name: Package Name
21+
ansible.builtin.set_fact:
22+
pkgname: >-
23+
{{ autobuild.git_repo.name }}-{{ pkgversion }}
24+
25+
- name: View Package Version
26+
ansible.builtin.debug:
27+
msg: >-
28+
{{ pkgversion }}
29+
30+
- name: Set pkgsource
31+
ansible.builtin.set_fact:
32+
pkgsource: >-
33+
{{ autobuild.git_repo.directory }}
34+
when: autobuild.build.script == "make"
35+
36+
- name: Set pkgsource
37+
ansible.builtin.set_fact:
38+
pkgsource: >-
39+
{{ autobuild.git_repo.directory }}/build
40+
when: autobuild.build.script == "cmake" or autobuild.build.script == "meson-ninja"
41+
42+
- name: Checkinstall Settings Generation
43+
ansible.builtin.set_fact:
44+
checkinstall:
45+
pkgname: "{{ pkgname }}"
46+
pkgrelease: "{{ item.major if item.major is defined else omit }}"
47+
pkgversion: "{{ pkgversion }}"
48+
pkgsource: "{{ pkgsource }}"
49+
provides: "{{ pkgname }}"
50+
maintainer: "{{ sudo_user }}@"
51+
pakdir: "{{ sudo_user_home }}/{{ build_paths.pkg_store }}"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# SPDX-FileCopyrightText: Copyright © 2026, Jared Cook
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
# Subroutine of pkg-source-build-routine
5+
# Purpose is to Generate 'update-alternatives' variable used in update-alternatives.yml
6+
7+
# @param item?: {raw_tag: string, project: string, major: string, minor: string, patch: string}
8+
---
9+
- name: Collect running user facts
10+
ansible.builtin.include_tasks: utilities/sudo_user_facts.yml
11+
when: sudo_user is not defined
12+
13+
- name: Initialize update-alternatives variables
14+
when: item is defined and autobuild is defined
15+
block:
16+
17+
- name: Generate empty update-alternatives variable
18+
ansible.builtin.set_fact:
19+
update_alternatives: null
20+
21+
- name: Update update-alternatives variable with link
22+
ansible.builtin.set_fact:
23+
update_alternatives: >-
24+
{{ update_alternatives
25+
| combine({'link': ( '/usr/bin/', git_repo.name ) | path_join})
26+
}}
27+
28+
- name: Update update-alternatives variable with name
29+
ansible.builtin.set_fact:
30+
update_alternatives: >-
31+
{{ update_alternatives
32+
| combine({'name': git_repo.name})
33+
}}
34+
35+
# TODO: Finish this so it isn't using checkinstall variable
36+
- name: Update update-alternatives variable with with installation path
37+
ansible.builtin.set_fact:
38+
update_alternatives: >-
39+
{{ update_alternatives
40+
| combine({'path': ( build_paths.install_path, autobuild.git_repo.name, pkgname ) | path_join})
41+
}}
42+
43+
44+
- name: Display 'update_alternatives' variable after initialization
45+
ansible.builtin.debug:
46+
msg: "{{ update_alternatives }}"
47+
when: update_alternatives is defined
48+
49+
# TODO: Maybe set option for priority otherwise it is always going to default back to 50.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# SPDX-FileCopyrightText: Copyright © 2026, Jared Cook
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
# This is a subroutine of pkg-source-build-routine
5+
---
6+
- name: Collect running user facts
7+
ansible.builtin.include_tasks: utilities/sudo_user_facts.yml
8+
when: sudo_user is not defined
9+
10+
- name: Source Build of {{ autobuild.git_repo.name }} using Cmake
11+
when: autobuild.git_repo is defined and autobuild.git_repo.directory is defined
12+
become: true
13+
become_user: "{{ sudo_user }}"
14+
block:
15+
# - name: Create a build directory
16+
# ansible.builtin.file:
17+
# path: "{{ project_build_dir }}/build"
18+
# state: directory
19+
20+
- name: Configure build for {{ autobuild.git_repo.name }} with Cmake
21+
ansible.builtin.shell:
22+
cmd: |
23+
"cmake ..
24+
-DCMAKE_BUILD_TYPE=Release
25+
-DCMAKE_INSTALL_PREFIX={{ autobuild.build.full_install_path }} > ansible-cmake.log
26+
executable: /bin/bash
27+
chdir: "{{ autobuild.git_repo.directory }}/build"
28+
29+
- name: Build {{ autobuild.git_repo.name }} with Make
30+
ansible.builtin.shell: make > ansible-make.log
31+
args:
32+
executable: /bin/bash
33+
chdir: "{{ autobuild.git_repo.directory }}/build"
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# SPDX-FileCopyrightText: Copyright © 2026, Jared Cook
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
# This is a subroutine of pkg-source-build-routine
5+
---
6+
- name: Collect running user facts
7+
ansible.builtin.include_tasks: utilities/sudo_user_facts.yml
8+
when: sudo_user is not defined
9+
10+
- name: Build {{ autobuild.git_repo.name }} from source using Make
11+
become: true
12+
become_user: "{{ sudo_user }}"
13+
when: autobuild.git_repo is defined and autobuild.git_repo.directory is defined
14+
block:
15+
- name: Clean {{ autobuild.git_repo.name }} with Make to ensure clean build
16+
ansible.builtin.command: make clean
17+
args:
18+
chdir: "{{ autobuild.git_repo.directory }}"
19+
become: true
20+
become_user: root
21+
22+
- name: Check if Autogen configure script exists
23+
ansible.builtin.stat:
24+
path: "{{ autobuild.git_repo.directory }}/configure"
25+
register: configure_check
26+
27+
- name: Make Configuration if using autogen
28+
when: configure_check.stat.exists
29+
block:
30+
# TODO: This same step will need to be added to cmake
31+
# NOTE: Assumed that this path is /opt/**
32+
- name: Ensure Installation Path exists
33+
ansible.builtin.file:
34+
path: "{{ autobuild.build.full_install_path }}"
35+
state: directory
36+
owner: root
37+
group: root
38+
mode: "0755"
39+
become: true
40+
become_user: root
41+
when: autobuild.build.full_install_path is defined
42+
43+
- name: Build Prefix Settings Generation
44+
ansible.builtin.set_fact:
45+
autobuild: >-
46+
{{ autobuild
47+
| combine({'build': autobuild.build
48+
| combine({'prefix': ('--prefix=', autobuild.build.full_install_path) | join('')})
49+
})
50+
}}
51+
52+
- name: View Build Variables
53+
ansible.builtin.debug:
54+
msg: "{{ autobuild.build }}"
55+
56+
- name: build configure
57+
ansible.builtin.set_fact:
58+
configure: >-
59+
{{ ['./configure', autobuild.build.prefix, autobuild.build.flags] | select('defined') | join(' ') }}
60+
61+
- name: View Build Variables
62+
ansible.builtin.debug:
63+
msg: "{{ configure }}"
64+
65+
- name: Run ./autogen.sh for autogen project {{ autobuild.git_repo.name }}
66+
ansible.builtin.shell: autogen.sh > ansible-autogen.log
67+
args:
68+
executable: /bin/bash
69+
chdir: "{{ autobuild.git_repo.directory }}"
70+
71+
- name: Run ./configure for autogen project {{ autobuild.git_repo.name }}
72+
ansible.builtin.shell: "{{ configure }} > ansible-configure.log"
73+
args:
74+
executable: /bin/bash
75+
chdir: "{{ autobuild.git_repo.directory }}"
76+
77+
- name: Build {{ autobuild.git_repo.name }} with Make
78+
ansible.builtin.shell: make > ansible-make.log
79+
args:
80+
executable: /bin/bash
81+
chdir: "{{ autobuild.git_repo.directory }}"

0 commit comments

Comments
 (0)