Compare commits

..

2 Commits

6 changed files with 315 additions and 2 deletions

View File

@ -38,11 +38,21 @@
fstype: xfs
state: mounted
- name: Install podman
- name: Install podman and components
ansible.builtin.yum:
name: podman
name:
- podman
- passt
- shadow-utils
state: latest
async: 1200
poll: 60
- name: Force reinstall container-selinux
ansible.builtin.yum:
name: container-selinux
state: reinstall
async: 1200
poll: 60

View File

@ -0,0 +1,164 @@
---
- hosts: beachsidelibrary
become: true
become_method: sudo
become_user: root
vars:
postgres_device: "/dev/vdc"
postgres_vg_name: "vg_postgres"
postgres_lv_name: "lv_pgdata"
postgres_data_directory: "/pgdata"
mysql_device: "/dev/vdd"
mysql_vg_name: "vg_mysql"
mysql_lv_name: "lv_mysql_data"
mysql_data_directory: "/mysql_data"
vars_prompt:
- name: psql_password
prompt: "Enter psql Password: "
private: true
encrypt: sha512_crypt
confirm: true
salt_size: 7
- name: mysql_password
prompt: "Enter mysql Password: "
private: true
encrypt: sha512_crypt
confirm: true
salt_size: 7
tasks:
- name: Create psql user
ansible.builtin.user:
name: psql
password: "{{ psql_password }}"
comment: "Podman user for Postgresql Database"
uid: 2000
- name: Build /pgdata mount
ansible.builtin.import_role:
name: make_lvm_mount
vars:
device_name: "{{ postgres_device }}"
vg_name: "{{ postgres_vg_name }}"
lvs:
- lv_name: "{{ postgres_lv_name }}"
lv_size: "100%FREE"
directories:
- name: "{{ postgres_data_directory }}"
owner: psql
group: psql
mode: "0755"
lv: "{{ postgres_lv_name }}"
- name: Create mysql user
ansible.builtin.user:
name: mysql
password: "{{ mysql_password }}"
comment: "Podman user for MySQL Database"
uid: 2001
- name: Build /mysql_data mount
ansible.builtin.import_role:
name: make_lvm_mount
vars:
device_name: "{{ mysql_device }}"
vg_name: "{{ mysql_vg_name }}"
lvs:
- lv_name: "{{ mysql_lv_name }}"
lv_size: "100%FREE"
directories:
- name: "{{ mysql_data_directory }}"
owner: mysql
group: mysql
mode: "0755"
lv: "{{ mysql_lv_name }}"
- name: Write subuid user entry for psql
ansible.builtin.lineinfile:
path: /etc/subuid
line: "psql:100000:2000"
insertafter: EOF
create: true
state: present
- name: Write subuid user entry for mysql
ansible.builtin.lineinfile:
path: /etc/subuid
line: "mysql:102000:2000"
insertafter: EOF
create: true
state: present
- name: Write subgid group entry for psql
ansible.builtin.lineinfile:
path: /etc/subgid
line: "psql:100000:2000"
insertafter: EOF
create: true
state: present
- name: Write subgid group entry for mysql
ansible.builtin.lineinfile:
path: /etc/subgid
line: "mysql:102000:2000"
insertafter: EOF
create: true
state: present
- name: Configure firewalld for postgres
ansible.posix.firewalld:
service: postgresql
state: enabled
permanent: true
immediate: true
- name: Configure firewalld for mysql
ansible.posix.firewalld:
service: mysql
state: enabled
permanent: true
immediate: true
- name: Build postgres quadlet
containers.podman.podman_container:
name: postgres
image: "postgres:latest"
state: quadlet
quadlet_filename: "postgres-quadlet"
quadlet_file_mode: "0640"
user: "psql"
ports:
- "5432:5432"
volumes:
- "{{ postgres_data_directory }}:/var/lib/postgresql/data"
quadlet_options:
- "AutoUpdate=registry"
- "Pull=newer"
- ""
- |
[Install]
WantedBy=default.target
env:
- POSTGRES_PASSWORD: "{{ psql_password }}"
- name: Build mysql quadlet
containers.podman.podman_container:
name: mysql
image: "mysql:latest"
state: quadlet
quadlet_filename: "mysql-quadlet"
quadlet_file_mode: "0640"
user: "mysql"
ports:
- "3306:3306"
volumes:
- "{{ mysql_data_directory }}:/var/lib/mysql"
quadlet_options:
- "AutoUpdate=registry"
- "Pull=newer"
- ""
- |
[Install]
WantedBy=default.target
env:
- MYSQL_ROOT_PASSWORD: "{{ psql_password }}"

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,12 @@
---
device_name: ""
vg_name: ""
lvs:
- lv_name: ""
lv_size: ""
directories:
- name: ""
owner: ""
group: ""
mode: ""
lv: ""

View File

@ -0,0 +1,53 @@
galaxy_info:
author: your name
description: your 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.4
# 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,36 @@
---
- name: Setup volume group
community.general.lvg:
vg: "{{ vg_name }}"
pvs: "{{ device_name }}"
- name: Setup logical volumes
community.general.lvol:
vg: "{{ vg_name }}"
lv: "{{ item.lv_name }}"
size: "{{ item.lv_size }}"
loop: "{{ lvs }}"
- name: Create xfs filesystem on lv
community.general.filesystem:
fstype: xfs
dev: "/dev/mapper/{{ vg_name }}-{{ item.lv_name }}"
loop: "{{ lvs }}"
- name: Create data directories
ansible.builtin.file:
path: "{{ item.name }}"
state: directory
owner: "{{ item.owner }}"
group: "{{ item.group }}"
mode: "{{ item.mode }}"
loop: "{{ directories }}"
- name: Setup mounts
ansible.posix.mount:
path: "{{ item.name }}"
src: "/dev/mapper/{{ vg_name }}-{{ item.lv }}"
fstype: xfs
state: mounted
loop: "{{ directories }}"