add role and molecule
This commit is contained in:
38
roles/xfs_project_quotas/README.md
Normal file
38
roles/xfs_project_quotas/README.md
Normal 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).
|
||||
2
roles/xfs_project_quotas/defaults/main.yml
Normal file
2
roles/xfs_project_quotas/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# defaults file for xfs_project_quotas
|
||||
2
roles/xfs_project_quotas/handlers/main.yml
Normal file
2
roles/xfs_project_quotas/handlers/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# handlers file for xfs_project_quotas
|
||||
16
roles/xfs_project_quotas/meta/main.yml
Normal file
16
roles/xfs_project_quotas/meta/main.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
galaxy_info:
|
||||
role_name: xfs_project_quotas
|
||||
namespace: genlab
|
||||
author: Alexander Gorelyshev
|
||||
company: Genlab, LLC
|
||||
description: ""
|
||||
license: GPL-2.0-or-later
|
||||
min_ansible_version: "2.1"
|
||||
|
||||
platforms:
|
||||
- name: Ubuntu
|
||||
versions: ["jammy", "noble"]
|
||||
|
||||
galaxy_tags: []
|
||||
|
||||
dependencies: []
|
||||
5
roles/xfs_project_quotas/molecule/default/converge.yml
Normal file
5
roles/xfs_project_quotas/molecule/default/converge.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- role: "genlab.common.xfs_project_quotas"
|
||||
27
roles/xfs_project_quotas/molecule/default/molecule.yml
Normal file
27
roles/xfs_project_quotas/molecule/default/molecule.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
|
||||
driver:
|
||||
name: docker
|
||||
|
||||
platforms:
|
||||
- name: ubuntu
|
||||
image: geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2404}-ansible:latest
|
||||
pre_build_image: true
|
||||
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||
cgroupns_mode: host
|
||||
privileged: true
|
||||
|
||||
provisioner:
|
||||
name: ansible
|
||||
|
||||
verifier:
|
||||
name: ansible
|
||||
|
||||
lint: |
|
||||
set -e
|
||||
yamllint .
|
||||
ansible-lint .
|
||||
11
roles/xfs_project_quotas/molecule/default/verify.yml
Normal file
11
roles/xfs_project_quotas/molecule/default/verify.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
|
||||
- name: Verify
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
any_errors_fatal: true
|
||||
|
||||
tasks:
|
||||
- name: Blank
|
||||
ansible.builtin.command: echo
|
||||
changed_when: false
|
||||
57
roles/xfs_project_quotas/tasks/main.yml
Normal file
57
roles/xfs_project_quotas/tasks/main.yml
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
- name: "Quotas | Ensure xfsprogs package is installed"
|
||||
ansible.builtin.apt:
|
||||
name: xfsprogs
|
||||
state: present
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: "Quotas | Ensure all /etc/projects entries exist"
|
||||
loop: "{{ projects }}"
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/projects
|
||||
state: present
|
||||
backup: true
|
||||
regexp: "^{{ item.id }}:"
|
||||
line: "{{ item.id }}:{{ item.path }}"
|
||||
|
||||
- name: "Quotas | Ensure all /etc/projects entries exist"
|
||||
loop: "{{ projects }}"
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/projid
|
||||
state: present
|
||||
backup: true
|
||||
regexp: "^{{ item.name }}:"
|
||||
line: "{{ item.name }}:{{ item.id }}"
|
||||
|
||||
- name: "Quotas | Ensure all project paths exist"
|
||||
loop: "{{ projects }}"
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
owner: "{{ item.owner }}"
|
||||
group: "{{ item.group }}"
|
||||
mode: "{{ item.mode }}"
|
||||
|
||||
- name: "Quotas | Initialize project quotas"
|
||||
changed_when: false
|
||||
loop: "{{ projects }}"
|
||||
ansible.builtin.command:
|
||||
cmd: >-
|
||||
xfs_quota
|
||||
-x
|
||||
-c
|
||||
'project -s {{ item.name }}'
|
||||
{{ storage_mountpoint }}
|
||||
|
||||
- name: "Quotas | Apply quota limits"
|
||||
loop: "{{ projects }}"
|
||||
community.general.xfs_quota:
|
||||
type: project
|
||||
name: "{{ item.name }}"
|
||||
mountpoint: "{{ storage_mountpoint }}"
|
||||
bsoft: "{{ item.bsoft | default('100G', false) }}"
|
||||
bhard: "{{ item.bhard | default('100G', false) }}"
|
||||
isoft: "{{ item.isoft | default(0, false) }}"
|
||||
ihard: "{{ item.ihard | default(0, false) }}"
|
||||
state: present
|
||||
2
roles/xfs_project_quotas/vars/main.yml
Normal file
2
roles/xfs_project_quotas/vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# vars file for xfs_project_quotas
|
||||
Reference in New Issue
Block a user