Changeset - d1387069c3c9
[Not reviewed]
0 7 0
Branko Majic (branko) - 5 months ago 2025-07-20 09:56:21
branko@majic.rs
MAR-244: Update copyright notices.
7 files changed with 12 insertions and 12 deletions:
0 comments (0 inline, 0 general)
LICENSE
Show inline comments
 
Copyright (c) 2018, Branko Majic
 
Copyright (c) 2018, 2025, Branko Majic
 
All rights reserved.
 

	
 
Redistribution and use in source and binary forms, with or without modification,
 
are permitted provided that the following conditions are met:
 

	
 
  Redistributions of source code must retain the above copyright notice, this
 
  list of conditions and the following disclaimer.
 

	
 
  Redistributions in binary form must reproduce the above copyright notice, this
 
  list of conditions and the following disclaimer in the documentation and/or
 
  other materials provided with the distribution.
 

	
 
  Neither the name of Branko Majic nor the names of any other
 
  contributors may be used to endorse or promote products derived from
 
  this software without specific prior written permission.
 

	
 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
 
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
docs/about.rst
Show inline comments
 
@@ -60,75 +60,75 @@ Features
 
   Of course, you may want to take some statements with a pinch of salt, and
 
   possibly attribute them to either delusions of grandeur, or bragging :)
 

	
 
* Emphasis on small, self-hosted deployments.
 
* Modular role design where possible and where necessary.
 
* A number of roles covering common set-up of servers, databases, web server,
 
  XMPP server, mail server, and LDAP server.
 
* Streamlined integration with LDAP server for most of the services.
 
* Well-documented, with role reference documentation, examples, and test/sample
 
  site.
 
* Balanced implementation allowing both configurability and ease of deployment.
 
* Free Software, released under liberal BSD license.
 

	
 
Available roles:
 

	
 
* ``bootstrap`` (for setting-up servers for Ansible use)
 
* ``common`` (for setting-up basic security, accounts, and configuration on
 
  servers)
 
* ``database`` (for creating databases to be used for applications)
 
* ``database_server`` (for deploying a database server, MariaDB)
 
* ``ldap_client`` (for setting-up LDAP client configuration)
 
* ``ldap_server`` (for deploying an LDAP server, OpenLDAP)
 
* ``mail_forwarder`` (for setting-up forwarding of local mails to smart host,
 
  Postfix)
 
* ``mail_server`` (for deploying Postfix, Dovecot, ClamAV)
 
* ``php_website`` (for deploying PHP websites)
 
* ``preseed`` (for preparing Debian preseed files)
 
* ``prosody`` (for deploying XMPP server, Prosody)
 
* ``web_server`` (for deploying web server, Nginx)
 
* ``wsgi_website`` (for deploying WSGI/Python applications)
 

	
 

	
 
Support
 
-------
 

	
 
In case of problems with the roles or provided code, please do not hestitate to
 
contact the author at **majic-ansible-roles (at) majic.rs**. The project can be
 
found at:
 

	
 
* https://code.majic.rs/majic-ansible-roles
 
* https://projects.majic.rs/majic-ansible-roles
 

	
 

	
 
License
 
-------
 

	
 
Majic Ansible Roles is released under terms of *BSD (3-Clause) License*::
 

	
 
  Copyright (c) 2018, Branko Majic
 
  Copyright (c) 2018, 2025, Branko Majic
 
  All rights reserved.
 

	
 
  Redistribution and use in source and binary forms, with or without modification,
 
  are permitted provided that the following conditions are met:
 

	
 
    Redistributions of source code must retain the above copyright notice, this
 
    list of conditions and the following disclaimer.
 

	
 
    Redistributions in binary form must reproduce the above copyright notice, this
 
    list of conditions and the following disclaimer in the documentation and/or
 
    other materials provided with the distribution.
 

	
 
    Neither the name of Branko Majic nor the names of any other
 
    contributors may be used to endorse or promote products derived from
 
    this software without specific prior written permission.
 

	
 
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
 
  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 
  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 
  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
roles/common/files/check_certificate.sh
Show inline comments
 
#!/bin/bash
 
#
 
# check_certificate.sh
 
#
 
# Copyright (C) 2017, Branko Majic <branko@majic.rs>
 
# Copyright (C) 2017, 2025, Branko Majic <branko@majic.rs>
 
#
 
# This program is free software: you can redistribute it and/or modify
 
# it under the terms of the GNU General Public License as published by
 
# the Free Software Foundation, either version 3 of the License, or
 
# (at your option) any later version.
 
#
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
#
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 
program="check_certificate.sh"
 

	
 
function usage() {
 
    cat <<EOF
 
$program, a non-interactive utility for checking certificates
 

	
 
Usage: $program [OPTIONS] check_type...
 

	
 
$program is a non-interactive utility for checking certificates. Utility
 
supports a number of different checks which are passed in as positional
 
arguments. The following checks are currently implemented:
 

	
 
expiration
 
  Checks if certificate expires within designated time. Expiration period can be
 
  specified via options (see below).
 

	
 
List of certificate files to check can be passed through two mutually exclusive
 
mechanisms - via options or through configuration files. If certificates are
 
specified through options, configuration files are not read.
 

	
 
Configuration files are by default read from directory
 
/etc/check_certificate/. Each configuration file is expected to end with
 
".conf". All other files will be ignored. A different configuration directory
 
can be also specified via an option.
 

	
 
Configuration files themselves should contain one certificate per line. Blank
 
lines will be ignored.
 

	
 

	
 
$program accepts the following options:
 

	
 
    -e period
 
        Number of days before certificate expires after which the certificate
 
        should be considered as about to expire. Value is used in the following
 
        check types: expiration.
 

	
 
    -c certificate_file
 
        Path to certificate file for which the checks should be run. This option
 
        can be specified multiple times on the command line in order to verify
 
        multiple certificates.
 

	
 
    -q
 
        Enable quiet mode. Output only warnings and errors.
 

	
 
    -d
 
        Enable debug output.
 

	
 
    -v
 
        Show script version and licensing information.
 

	
 
    -h
 
        Show usage help.
 

	
 

	
 
Please report bugs and send feature requests to <branko@majic.rs>.
 
EOF
 
}
 

	
 
function version() {
 
        cat <<EOF
 
$program
 

	
 
+-----------------------------------------------------------------------+
 
| Copyright (C) 2017, Branko Majic <branko@majic.rs>                    |
 
| Copyright (C) 2017, 2025, Branko Majic <branko@majic.rs>              |
 
|                                                                       |
 
| This program is free software: you can redistribute it and/or modify  |
 
| it under the terms of the GNU General Public License as published by  |
 
| the Free Software Foundation, either version 3 of the License, or     |
 
| (at your option) any later version.                                   |
 
|                                                                       |
 
| This program is distributed in the hope that it will be useful,       |
 
| but WITHOUT ANY WARRANTY; without even the implied warranty of        |
 
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
 
| GNU General Public License for more details.                          |
 
|                                                                       |
 
| You should have received a copy of the GNU General Public License     |
 
| along with this program.  If not, see <http://www.gnu.org/licenses/>. |
 
+-----------------------------------------------------------------------+
 

	
 
EOF
 
}
 

	
 
# Set-up colours for message printing if we're not piping and terminal is
 
# capable of outputting the colors.
 
_color_terminal=$(tput colors 2>&1)
 
if [[ -t 1 ]] && (( ${_color_terminal} > 0 )); then
 
    _text_bold=$(tput bold)
 
    _text_white=$(tput setaf 7)
 
    _text_blue=$(tput setaf 6)
 
    _text_green=$(tput setaf 2)
 
    _text_yellow=$(tput setaf 3)
 
    _text_red=$(tput setaf 1)
 
    _text_reset=$(tput sgr0)
 
else
 
    _text_bold=""
 
    _text_white=""
 
    _text_blue=""
 
    _text_green=""
 
    _text_yellow=""
 
    _text_red=""
 
    _text_reset=""
 
fi
 

	
 
# Set-up functions for printing coloured messages.
 
function debug() {
 
    [[ $DEBUG != 0 ]] && echo "${_text_bold}${_text_blue}[DEBUG]${_text_reset}" "$@"
 
}
 

	
 
function info() {
 
    [[ $QUIET == 0 ]] && echo "${_text_bold}${_text_white}[INFO] ${_text_reset}" "$@"
 
}
 

	
roles/common/files/legacy_iptables_rules.sh
Show inline comments
 
#!/bin/bash
 
#
 
# legacy_iptables_rules.sh
 
#
 
# Copyright (C) 2023, Branko Majic <branko@majic.rs>
 
# Copyright (C) 2023, 2025, Branko Majic <branko@majic.rs>
 
#
 
# This program is free software: you can redistribute it and/or modify
 
# it under the terms of the GNU General Public License as published by
 
# the Free Software Foundation, either version 3 of the License, or
 
# (at your option) any later version.
 
#
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
#
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 
# Treat unset variables as errors.
 
set -u
 

	
 
PROGRAM="legacy_iptables_rules.sh"
 

	
 
function usage() {
 
    cat <<EOF
 
$PROGRAM, helper tool for removing legacy iptables rules
 

	
 
Usage:
 
  $PROGRAM [OPTIONS] remove
 
EOF
 
}
 

	
 
function short_help() {
 
    cat <<EOF
 
$(usage)
 

	
 
For more details see $PROGRAM -h.
 
EOF
 
}
 

	
 
function long_help() {
 
    cat <<EOF
 
$(usage)
 

	
 
$PROGRAM is a helper tool that can be used to remove the legacy
 
iptables rules.
 

	
 
The tool works by resetting the default policies on all the relevant
 
chains and tables, flushing the rules, as well as unloading the
 
related kernel modules.
 

	
 
Tool implements multiple commands, as documented below.
 

	
 
  remove
 

	
 
    Removes the legacy iptables rules.
 

	
 
$PROGRAM accepts the following options:
 

	
 
    -q
 
        Quiet mode.
 
    -d
 
        Enable debug mode.
 
    -v
 
        Show script version and licensing information.
 
    -h
 
        Show full help.
 

	
 
Please report bugs and send feature requests to <branko@majic.rs>.
 
EOF
 
}
 

	
 
function version() {
 
    cat <<EOF
 
$PROGRAM
 

	
 
+-----------------------------------------------------------------------+
 
| Copyright (C) 2023, Branko Majic <branko@majic.rs>                    |
 
| Copyright (C) 2023, 2025, Branko Majic <branko@majic.rs>              |
 
|                                                                       |
 
| This program is free software: you can redistribute it and/or modify  |
 
| it under the terms of the GNU General Public License as published by  |
 
| the Free Software Foundation, either version 3 of the License, or     |
 
| (at your option) any later version.                                   |
 
|                                                                       |
 
| This program is distributed in the hope that it will be useful,       |
 
| but WITHOUT ANY WARRANTY; without even the implied warranty of        |
 
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
 
| GNU General Public License for more details.                          |
 
|                                                                       |
 
| You should have received a copy of the GNU General Public License     |
 
| along with this program.  If not, see <http://www.gnu.org/licenses/>. |
 
+-----------------------------------------------------------------------+
 

	
 
EOF
 
}
 

	
 
# Set-up colours for message printing if we're not piping and terminal is
 
# capable of outputting the colors.
 
_COLOR_TERMINAL=$(tput colors 2>&1)
 
if [[ -t 1 ]] && (( _COLOR_TERMINAL > 0 )); then
 
    _TEXT_BOLD=$(tput bold)
 
    _TEXT_WHITE=$(tput setaf 7)
 
    _TEXT_BLUE=$(tput setaf 6)
 
    _TEXT_GREEN=$(tput setaf 2)
 
    _TEXT_YELLOW=$(tput setaf 3)
 
    _TEXT_RED=$(tput setaf 1)
 
    _TEXT_RESET=$(tput sgr0)
 
else
 
    _TEXT_BOLD=""
 
    _TEXT_WHITE=""
 
    _TEXT_BLUE=""
 
    _TEXT_GREEN=""
 
    _TEXT_YELLOW=""
 
    _TEXT_RED=""
 
    _TEXT_RESET=""
 
fi
 

	
 
# Set-up functions for printing coloured messages.
 
function debug() {
 
    if [[ $DEBUG != 0 ]]; then
 
        echo "${_TEXT_BOLD}${_TEXT_BLUE}[DEBUG]${_TEXT_RESET}" "$@"
 
    fi
 
}
 

	
 
function info() {
 
    if [[ $QUIET == 0 ]]; then
roles/common/files/pip_check_requirements_upgrades.sh
Show inline comments
 
#!/bin/bash
 
#
 
# pip_check_requirements_upgrades.sh
 
#
 
# Copyright (C) 2017, Branko Majic <branko@majic.rs>
 
# Copyright (C) 2017, 2025, Branko Majic <branko@majic.rs>
 
#
 
# This program is free software: you can redistribute it and/or modify
 
# it under the terms of the GNU General Public License as published by
 
# the Free Software Foundation, either version 3 of the License, or
 
# (at your option) any later version.
 
#
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
#
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 
program="pip_check_requirements_upgrades.sh"
 

	
 
function usage() {
 
    cat <<EOF
 
$program, a non-interactive utility for checking for available upgrades in
 
Python pip requirements files based on pip-tools
 

	
 
Usage: $program [OPTIONS] configuration_directory
 

	
 
$program a non-interactive utility for checking for available upgrades in Python
 
pip requirements files based on pip-tools. Utility is written specifically with
 
pip-tools in mind, and pip-tools must be available when running the utility.
 

	
 
If you are unfamiliar with pip-tools, please read its documentation first, and
 
make sure you fully understand how it works.
 

	
 
Utility accepts a single positionl argument - path to configuration
 
directory. Configuration directory should contain one or more sub-directories
 
where each sub-directory is treated as describing a separate Python virtual
 
environment. This allows the checks to be run for multiple virtual environments
 
in a modular manner.
 

	
 
Each sub-directory should contain one or more .in files with corresponding .txt
 
file. Base names must match (i.e. if you have production.in, the requirements
 
file must be called production.txt).
 

	
 
Utility iterates over each .in/.txt pair, calculates new requirements
 
based on the .in file, and diffs this against existing .txt file. If a
 
.in file does not have a corresponding .txt file, it is ignored
 
(making it possible to use the '-r base.in' syntax for including base
 
requirements etc).
 

	
 
Utility creates copy of existing requirements file, stripping it from all
 
comments, then calculates new requirements file (storing result in temporary
 
location as well), and runs a diff between them.
 

	
 
If newer pacakges are available that would satisfiy the provided .in file, a
 
diff is shown on standard output in addition to a warning message.
 

	
 
$program accepts the following options:
 

	
 
    -V virtualenv
 
        Path to virtual environment with pre-installed pip-tools. If specified,
 
        the virtual environment will be activated prior to running the utility.
 

	
 
    -q
 
        Quiet mode. Output a message only if newer packages are available.
 
    -d
 
        Enable debug mode.
 
    -v
 
        Show script licensing information.
 
    -h
 
        Show usage help.
 

	
 

	
 
Please report bugs and send feature requests to <branko@majic.rs>.
 
EOF
 
}
 

	
 
function version() {
 
    cat <<EOF
 
$program
 

	
 
+-----------------------------------------------------------------------+
 
| Copyright (C) 2017, Branko Majic <branko@majic.rs>                    |
 
| Copyright (C) 2017, 2025, Branko Majic <branko@majic.rs>              |
 
|                                                                       |
 
| This program is free software: you can redistribute it and/or modify  |
 
| it under the terms of the GNU General Public License as published by  |
 
| the Free Software Foundation, either version 3 of the License, or     |
 
| (at your option) any later version.                                   |
 
|                                                                       |
 
| This program is distributed in the hope that it will be useful,       |
 
| but WITHOUT ANY WARRANTY; without even the implied warranty of        |
 
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
 
| GNU General Public License for more details.                          |
 
|                                                                       |
 
| You should have received a copy of the GNU General Public License     |
 
| along with this program.  If not, see <http://www.gnu.org/licenses/>. |
 
+-----------------------------------------------------------------------+
 

	
 
EOF
 
}
 

	
 
# Set-up colours for message printing if we're not piping and terminal is
 
# capable of outputting the colors.
 
_color_terminal=$(tput colors 2>&1)
 
if [[ -t 1 ]] && (( _color_terminal > 0 )); then
 
    _text_bold=$(tput bold)
 
    _text_white=$(tput setaf 7)
 
    _text_blue=$(tput setaf 6)
 
    _text_green=$(tput setaf 2)
 
    _text_yellow=$(tput setaf 3)
 
    _text_red=$(tput setaf 1)
 
    _text_reset=$(tput sgr0)
 
else
 
    _text_bold=""
 
    _text_white=""
 
    _text_blue=""
 
    _text_green=""
 
    _text_yellow=""
 
    _text_red=""
 
    _text_reset=""
 
fi
 

	
 
# Set-up functions for printing coloured messages.
 
function debug() {
 
    if [[ $debug != 0 ]]; then
 
        echo -e "${_text_bold}${_text_blue}[DEBUG]${_text_reset}" "$@"
 
    fi
 
}
 

	
 
function info() {
 
    echo -e "${_text_bold}${_text_white}[INFO] ${_text_reset}" "$@"
roles/web_server/files/nginx_verify_site.sh
Show inline comments
 
#!/bin/bash
 
#
 
# nginx_verify_site.sh
 
#
 
# Copyright (C) 2016, Branko Majic <branko@majic.rs>
 
# Copyright (C) 2016, 2025, Branko Majic <branko@majic.rs>
 
#
 
# This program is free software: you can redistribute it and/or modify
 
# it under the terms of the GNU General Public License as published by
 
# the Free Software Foundation, either version 3 of the License, or
 
# (at your option) any later version.
 
#
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
#
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 
program="nginx_verify_site.sh"
 
version="0.1"
 

	
 
function usage() {
 
    cat <<EOF
 
$program $version, a non-interactive utility for testing a new nginx site configuration file
 

	
 
Usage: $program [OPTIONS] site_configuration_file
 

	
 
$program is a non-interactive utility for testing a new nginx site configuration
 
file. The utility works by copying the existing nginx configuration to a
 
temporary path, deploying the passed-in site configuration file to the temporary
 
location, and running the nginx -t command on temporary configuration
 
copy. During this process the utility will also fix the paths in temporary
 
configuration files on the fly.
 

	
 
A single positional argument is accepted:
 

	
 
site_configuration_file
 
  Path to the (new) file containing the site configuration that should be
 
  tested.
 

	
 
$program accepts the following options:
 

	
 
    -n name   Name to use for site configuration file. Useful when combined with
 
              Ansible's validate command (modules copy/template) which does not
 
              preserve filenames when executed. Defaults to original filename
 
              for site_configuration_file.
 

	
 
    -v        show script version and licensing information
 
    -h        show usage help
 

	
 

	
 
Please report bugs and send feature requests to <branko@majic.rs>.
 
EOF
 
}
 

	
 
function version() {
 
        cat <<EOF
 
$program, version $version
 

	
 
+-----------------------------------------------------------------------+
 
| Copyright (C) 2016, Branko Majic <branko@majic.rs>                    |
 
| Copyright (C) 2016, 2025, Branko Majic <branko@majic.rs>              |
 
|                                                                       |
 
| This program is free software: you can redistribute it and/or modify  |
 
| it under the terms of the GNU General Public License as published by  |
 
| the Free Software Foundation, either version 3 of the License, or     |
 
| (at your option) any later version.                                   |
 
|                                                                       |
 
| This program is distributed in the hope that it will be useful,       |
 
| but WITHOUT ANY WARRANTY; without even the implied warranty of        |
 
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
 
| GNU General Public License for more details.                          |
 
|                                                                       |
 
| You should have received a copy of the GNU General Public License     |
 
| along with this program.  If not, see <http://www.gnu.org/licenses/>. |
 
+-----------------------------------------------------------------------+
 

	
 
EOF
 
}
 

	
 
# Set-up colours for message printing if we're not piping and terminal is
 
# capable of outputting the colors.
 
_color_terminal=$(tput colors 2>&1)
 
if [[ -t 1 ]] && (( ${_color_terminal} > 0 )); then
 
    _text_bold=$(tput bold)
 
    _text_white=$(tput setaf 7)
 
    _text_blue=$(tput setaf 6)
 
    _text_green=$(tput setaf 2)
 
    _text_yellow=$(tput setaf 3)
 
    _text_red=$(tput setaf 1)
 
    _text_reset=$(tput sgr0)
 
else
 
    _text_bold=""
 
    _text_white=""
 
    _text_blue=""
 
    _text_green=""
 
    _text_yellow=""
 
    _text_red=""
 
    _text_reset=""
 
fi
 

	
 
# Set-up functions for printing coloured messages.
 
function debug() {
 
    echo "${_text_bold}${_text_blue}[DEBUG]${_text_reset}" "$@"
 
}
 

	
 
function info() {
 
    echo "${_text_bold}${_text_white}[INFO] ${_text_reset}" "$@"
 
}
 

	
scripts/run_tests.sh
Show inline comments
 
#!/bin/bash
 
#
 
# run_tests.sh
 
#
 
# Copyright (C) 2017, Branko Majic <branko@majic.rs>
 
# Copyright (C) 2017, 2025, Branko Majic <branko@majic.rs>
 
#
 
# This program is free software: you can redistribute it and/or modify
 
# it under the terms of the GNU General Public License as published by
 
# the Free Software Foundation, either version 3 of the License, or
 
# (at your option) any later version.
 
#
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
#
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 
program="run_tests.sh"
 

	
 
function usage() {
 
    cat <<EOF
 
$program, a non-interactive utility for running role tests for Majic Ansible
 
Roles
 

	
 
Usage: $program [OPTIONS] (all|role1 ... roleN)
 

	
 
$program is a non-interactive utility for running role tests for Majic Ansible
 
Roles.
 

	
 
The script iterates over all roles within sub-directory "roles" (relative to
 
working directory) that have a valid Molecule configuration, runs the tests, and
 
optionally writes report for all tested roles (see option -r).
 

	
 
Only the default scenario is tested at the moment.
 

	
 
$program accepts the following options:
 

	
 
    -r
 
        Generate report for all roles under sub-directory of current
 
        directory "test_report-YYYY_MM_DD-hh_mm". Within the
 
        sub-directory each role will have its own file named
 
        "role-ROLENAME.txt". In addition, a summary file (summary.txt)
 
        is produced with overview of which roles have passed, failed,
 
        and which roles were skipped.
 

	
 
    -l all|lint
 
        Limit what type of tests should be run. Currently supported
 
        values are:
 

	
 
        all
 
            Runs all the available tests. This is the default.
 

	
 
        lint
 
            Runs only the linting tests. This is useful for performing
 
            a quick check on syntax prior to running more extensive
 
            testing.
 

	
 
    -d
 
        Enable debug mode.
 
    -v
 
        Show script licensing information.
 
    -h
 
        Show usage help.
 

	
 

	
 
Please report bugs and send feature requests to <branko@majic.rs>.
 
EOF
 
}
 

	
 
function version() {
 
    cat <<EOF
 
$program
 

	
 
+-----------------------------------------------------------------------+
 
| Copyright (C) 2017, Branko Majic <branko@majic.rs>                    |
 
| Copyright (C) 2017, 2025, Branko Majic <branko@majic.rs>              |
 
|                                                                       |
 
| This program is free software: you can redistribute it and/or modify  |
 
| it under the terms of the GNU General Public License as published by  |
 
| the Free Software Foundation, either version 3 of the License, or     |
 
| (at your option) any later version.                                   |
 
|                                                                       |
 
| This program is distributed in the hope that it will be useful,       |
 
| but WITHOUT ANY WARRANTY; without even the implied warranty of        |
 
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
 
| GNU General Public License for more details.                          |
 
|                                                                       |
 
| You should have received a copy of the GNU General Public License     |
 
| along with this program.  If not, see <http://www.gnu.org/licenses/>. |
 
+-----------------------------------------------------------------------+
 

	
 
EOF
 
}
 

	
 
# Set-up colours for message printing if we're not piping and terminal is
 
# capable of outputting the colors.
 
_color_terminal=$(tput colors 2>&1)
 
if [[ -t 1 ]] && (( _color_terminal > 0 )); then
 
    _text_bold=$(tput bold)
 
    _text_white=$(tput setaf 7)
 
    _text_blue=$(tput setaf 6)
 
    _text_green=$(tput setaf 2)
 
    _text_yellow=$(tput setaf 3)
 
    _text_red=$(tput setaf 1)
 
    _text_reset=$(tput sgr0)
 
else
 
    _text_bold=""
 
    _text_white=""
 
    _text_blue=""
 
    _text_green=""
 
    _text_yellow=""
 
    _text_red=""
 
    _text_reset=""
 
fi
 

	
 
# Set-up functions for printing coloured messages.
 
function debug() {
 
    if [[ $debug != 0 ]]; then
 
        echo "${_text_bold}${_text_blue}[DEBUG]${_text_reset}" "$@"
 
    fi
 
}
 

	
 
function info() {
 
    echo "${_text_bold}${_text_white}[INFO] ${_text_reset}" "$@"
0 comments (0 inline, 0 general)