first commit

This commit is contained in:
Ryan Cuda
2026-01-25 08:31:56 -07:00
commit 1234ef51c0
57 changed files with 2560 additions and 0 deletions

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,5 @@
# defaults/main.yml
---
apache_packages:
- httpd
- firewalld

View File

@@ -0,0 +1,6 @@
# handlers/main.yml
---
- name: restart httpd
ansible.builtin.service:
name: httpd
state: restarted

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.

View File

@@ -0,0 +1,34 @@
# tasks/main.yml
---
- name: Install httpd and firewalld
ansible.builtin.package:
name: "{{ apache_packages }}"
state: present
- name: Enable and start firewalld
ansible.builtin.service:
name: firewalld
state: started
enabled: true
- name: Enable and start httpd
ansible.builtin.service:
name: httpd
state: started
enabled: true
- name: Allow HTTP service through firewalld
ansible.posix.firewalld:
service: http
permanent: true
state: enabled
immediate: true
- name: Deploy index.html with FQDN and IPv4
ansible.builtin.template:
src: index.html.j2
dest: /var/www/html/index.html
owner: root
group: root
mode: '0644'
notify: restart httpd

View File

@@ -0,0 +1,12 @@
# templates/index.html.j2
<!DOCTYPE html>
<html>
<head>
<title>Apache Test Page</title>
</head>
<body>
<h1>Apache is working</h1>
<p><strong>FQDN:</strong> {{ ansible_facts.fqdn }}</p>
<p><strong>IPv4 Address:</strong> {{ ansible_facts.default_ipv4.address }}</p>
</body>
</html>

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,19 @@
{
"collection_info": null,
"dependencies": [],
"format": 1,
"license": "MIT",
"license_file": null,
"name": "balancer",
"namespace": "local",
"readme": "README.md",
"repository": null,
"tags": [
"haproxy",
"loadbalancer",
"networking",
"web"
],
"version": "1.0.0"
}

View File

@@ -0,0 +1,11 @@
---
haproxy_frontend_port: 80
haproxy_backend_servers:
- name: node3
address: node3
port: 80
- name: node4
address: node4
port: 80

View File

@@ -0,0 +1,6 @@
---
- name: Restart haproxy
ansible.builtin.service:
name: haproxy
state: restarted

View File

@@ -0,0 +1,2 @@
install_date: 'Tue 30 Dec 2025 12:53:11 AM '
version: ''

View File

@@ -0,0 +1,21 @@
---
galaxy_info:
role_name: balancer
author: lab
description: Installs and configures HAProxy to load balance Apache servers
license: MIT
min_ansible_version: "2.9"
platforms:
- name: EL
versions:
- "9"
galaxy_tags:
- haproxy
- loadbalancer
- networking
- web
dependencies: []

View File

@@ -0,0 +1,28 @@
---
- name: Install HAProxy
ansible.builtin.dnf:
name: haproxy
state: present
- name: Enable and start HAProxy
ansible.builtin.service:
name: haproxy
state: started
enabled: true
- name: Deploy HAProxy configuration
ansible.builtin.template:
src: haproxy.cfg.j2
dest: /etc/haproxy/haproxy.cfg
owner: root
group: root
mode: '0644'
notify: Restart haproxy
- name: Allow port 80 through firewalld
ansible.posix.firewalld:
service: http
permanent: true
immediate: true
state: enabled

View File

@@ -0,0 +1,25 @@
global
log /dev/log local0
log /dev/log local1 notice
daemon
maxconn 2048
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5s
timeout client 50s
timeout server 50s
frontend http_front
bind *:80
default_backend webservers
backend webservers
balance roundrobin
option httpchk
server node3 node3:80 check
server node4 node4:80 check

View File

@@ -0,0 +1,17 @@
# phpinfo Role
This role installs Apache, PHP, and Firewalld, opens HTTP access, fixes SELinux
contexts, and deploys a PHP info page.
## Requirements
- RHEL / Rocky / Alma 9
- SELinux enforcing
- firewalld enabled
## Usage
```yaml
- hosts: web
become: true
roles:
- phpinfo

View File

@@ -0,0 +1,4 @@
---
phpinfo_webroot: /var/www/html
phpinfo_file: index.php

View File

@@ -0,0 +1,6 @@
---
- name: Restart httpd
ansible.builtin.service:
name: httpd
state: restarted

View File

@@ -0,0 +1,2 @@
install_date: 'Tue 30 Dec 2025 12:53:11 AM '
version: ''

View File

@@ -0,0 +1,22 @@
---
galaxy_info:
role_name: phpinfo
author: lab
description: Installs Apache, PHP, configures firewalld, fixes SELinux, and deploys a PHP info page
license: MIT
min_ansible_version: "2.9"
platforms:
- name: EL
versions:
- "9"
galaxy_tags:
- php
- httpd
- firewalld
- selinux
- web
dependencies: []

View File

@@ -0,0 +1,41 @@
---
- name: Install required packages
ansible.builtin.dnf:
name:
- httpd
- firewalld
- php
state: present
- name: Enable and start httpd
ansible.builtin.service:
name: httpd
state: started
enabled: true
- name: Enable and start firewalld
ansible.builtin.service:
name: firewalld
state: started
enabled: true
- name: Allow HTTP traffic through firewalld (persistent and immediate)
ansible.posix.firewalld:
service: http
state: enabled
permanent: true
immediate: true
- name: Fix SELinux context on webroot
ansible.builtin.command: restorecon -Rv {{ phpinfo_webroot }}
changed_when: false
- name: Deploy PHP info page
ansible.builtin.template:
src: index.php.j2
dest: "{{ phpinfo_webroot }}/{{ phpinfo_file }}"
owner: root
group: root
mode: '0644'
notify: Restart httpd

View File

@@ -0,0 +1,4 @@
<?php
phpinfo();
?>

View File

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

View File

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

View File

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