diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000..937b336 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,19 @@ +--- +# +# Ansible managed +# +exclude_paths: + - molecule/default/prepare.yml + - molecule/default/converge.yml + - molecule/default/verify.yml + - molecule/default/collections.yml + - .tox + - .cache + - .github + - requirements.yml + +skip_list: + - yaml[truthy] + +enable_list: + - name[prefix] diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..1885b22 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +--- +github: adfinis diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..f616070 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,30 @@ +--- +name: Bug report +about: Create a report to help me improve + +--- + +# Describe the bug + +A clear and concise description of what the bug is. + +## Playbook + +Please paste the playbook you are using. (Consider `requirements.yml` and +optionally the command you've invoked.) + +```yaml +--- +YOUR PLAYBOOK HERE +``` + +## Output + +Show at least the error, possible related output, maybe just all the output. + +## Environment + +- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) +- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) +- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..f13966d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,18 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + +# Proposed feature + +A clear and concise description of what you want to happen. + +## Rationale + +Why is this feature required? + +## Additional context + +Add any other context about the feature request here. + diff --git a/.github/settings.yml b/.github/settings.yml new file mode 100644 index 0000000..27940fc --- /dev/null +++ b/.github/settings.yml @@ -0,0 +1,8 @@ +--- +# +# Ansible managed +# +repository: + description: Install and configure [Bareos](https://www.bareos.com/) Console (bconsole) on your system. + homepage: https://adfinis.com/ + topics: backup, bareos, infrastructure, linux, storage, system, tools, ansible, molecule, tox, playbook diff --git a/.github/workflows/galaxy.yml b/.github/workflows/galaxy.yml new file mode 100644 index 0000000..1f8d455 --- /dev/null +++ b/.github/workflows/galaxy.yml @@ -0,0 +1,18 @@ +--- +# +# Ansible managed +# + +name: Release to Ansible Galaxy + +on: + release: + types: [created, edited, published, released] +jobs: + release: + runs-on: ubuntu-20.04 + steps: + - name: galaxy + uses: robertdebock/galaxy-action@1.2.1 + with: + galaxy_api_key: ${{ secrets.galaxy_api_key }} diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml new file mode 100644 index 0000000..90164c9 --- /dev/null +++ b/.github/workflows/molecule.yml @@ -0,0 +1,67 @@ +--- +# +# Ansible managed +# + +name: Ansible Molecule + +on: + push: + tags_ignore: + - '*' + pull_request: + schedule: + - cron: '3 2 2 * *' + +jobs: + lint: + runs-on: ubuntu-20.04 + steps: + - name: checkout + uses: actions/checkout@v3 + - name: ansible-lint + uses: ansible-community/ansible-lint-action@main + test: + needs: + - lint + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + config: + - image: "debian" + tag: "latest" + - image: "debian" + tag: "bullseye" + - image: "debian" + tag: "buster" + - image: "enterpriselinux" + tag: "7" + - image: "enterpriselinux" + tag: "8" + - image: "enterpriselinux" + tag: "latest" + - image: "fedora" + tag: "37" + - image: "fedora" + tag: "38" + - image: "opensuse" + tag: "latest" + - image: "ubuntu" + tag: "latest" + - image: "ubuntu" + tag: "focal" + steps: + - name: checkout + uses: actions/checkout@v3 + with: + path: "${{ github.repository }}" + - name: disable apparmor for mysql + run: sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ + - name: parse apparmor for mysql + run: sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld + - name: molecule + uses: robertdebock/molecule-action@6.0.0 + with: + image: ${{ matrix.config.image }} + tag: ${{ matrix.config.tag }} diff --git a/.github/workflows/requirements2png.yml b/.github/workflows/requirements2png.yml new file mode 100644 index 0000000..6ce9be7 --- /dev/null +++ b/.github/workflows/requirements2png.yml @@ -0,0 +1,35 @@ +--- +# +# Ansible managed +# + +on: + - push + +name: Ansible Graphviz + +jobs: + build: + runs-on: ubuntu-20.04 + permissions: + contents: write + steps: + - name: checkout + uses: actions/checkout@v3 + with: + path: ${{ github.repository }} + - name: create png + uses: robertdebock/graphviz-action@1.0.7 + - name: Commit files + run: | + cd ${{ github.repository }} + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add requirements.dot requirements.png + git commit -m "Add generated files" + - name: save to png branch + uses: ad-m/github-push-action@master + with: + directory: ${{ github.repository }} + force: true + branch: png diff --git a/.github/workflows/todo.yml b/.github/workflows/todo.yml new file mode 100644 index 0000000..3e6e417 --- /dev/null +++ b/.github/workflows/todo.yml @@ -0,0 +1,20 @@ +--- +# +# Ansible managed +# + +name: "TODO 2 Issue" + +on: + push: + +jobs: + build: + runs-on: "ubuntu-20.04" + steps: + - uses: "actions/checkout@master" + - name: "TODO to Issue" + uses: "alstr/todo-to-issue-action@v2.3" + id: "todo" + with: + TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ad73ff6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.molecule +*.log +*.swp +.tox +.cache +.DS_Store diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..679c2d2 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,42 @@ +--- +image: "robertdebock/github-action-molecule:6.0.0" + +variables: + PY_COLORS: 1 + +molecule: + script: + - if [ -f tox.ini ] ; then tox ; fi + - if [ ! -f tox.ini ] ; then molecule test ; fi + rules: + - if: $CI_COMMIT_REF_NAME == "master" + parallel: + matrix: + - image: "debian" + tag: "latest" + - image: "debian" + tag: "bullseye" + - image: "debian" + tag: "buster" + - image: "enterpriselinux" + tag: "7" + - image: "enterpriselinux" + tag: "8" + - image: "enterpriselinux" + tag: "latest" + - image: "fedora" + tag: "37" + - image: "fedora" + tag: "38" + - image: "opensuse" + tag: "latest" + - image: "ubuntu" + tag: "latest" + - image: "ubuntu" + tag: "focal" + +galaxy: + script: + - ansible-galaxy role import --api-key ${GALAXY_API_KEY} adfinis ${CI_PROJECT_NAME} + rules: + - if: $CI_COMMIT_TAG != null diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..547e418 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +--- +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-added-large-files + + - repo: https://github.com/adrienverge/yamllint + rev: v1.32.0 + hooks: + - id: yamllint + args: + - -c=.yamllint + + - repo: https://github.com/robertdebock/pre-commit + rev: v1.5.2 + hooks: + - id: ansible_role_find_unused_variable + - id: ansible_role_find_empty_files + - id: ansible_role_find_empty_directories + - id: ansible_role_find_undefined_handlers + - id: ansible_role_find_unquoted_values + - id: ansible_role_find_horizontal_when diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..a7ff098 --- /dev/null +++ b/.yamllint @@ -0,0 +1,16 @@ +--- +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + line-length: disable + truthy: disable + +ignore: | + .tox/ + .cache/ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..0d97a6f --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behaviour that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behaviour by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behaviour and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behaviour. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviours that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behaviour may be reported by contacting the project team at robert@meinit.nl. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..38342ff --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,76 @@ +# [Please contribute](#please-contribute) + +You can really make a difference by: + +- [Making an issue](https://help.github.com/articles/creating-an-issue/). A well described issue helps a lot. (Have a look at the [known issues](https://github.com/search?q=user%3Aadfinis+is%3Aissue+state%3Aopen).) +- [Making a pull request](https://services.github.com/on-demand/github-cli/open-pull-request-github) when you see the error in code. + +I'll try to help and take every contribution seriously. + +It's a great opportunity for me to learn how you use the role and also an opportunity to get into the habit of contributing to open source software. + +## [Step by step](#step-by-step) + +Here is how you can help, a lot of steps are related to GitHub, not specifically my roles. + +### [1. Make an issue.](#1-make-an-issue) + +When you spot an issue, [create an issue](https://github.com/adfinis/ansible-role-bareos_console/issues). + +Making the issue help me and others to find similar problems in the future. + +### [2. Fork the project.](#2-fork-the-project) + +On the top right side of [the repository on GitHub](https://github.com/adfinis/ansible-role-bareos_console), click `fork`. This copies everything to your GitHub namespace. + +### [3. Make the changes](#3-make-the-changes) + +In you own GitHub namespace, make the required changes. + +I typically do that by cloning the repository (in your namespace) locally: + +``` +git clone git@github.com:YOURNAMESPACE/ansible-role-bareos_console.git +``` + +Now you can start to edit on your laptop. + +### [4. Optionally: test your changes](#4-optionally-test-your-changes) + +Install [molecule](https://molecule.readthedocs.io/en/stable/) and [Tox](https://tox.readthedocs.io/): + +``` +pip install molecule tox ansible-lint docker +``` + +And run `molecule test`. If you want to test a specific distribution, set `image` and optionally `tag`: + +``` +image=centos tag=7 molecule test +``` + +Once it start to work, you can test multiple version of Ansible: + +``` +image=centos tag=7 tox +``` + +### [5. Optionally: Regenerate all dynamic content](#5-optionally-regenerate-all-dynamic-content) + +You can use [Ansible Generator](https://github.com/robertdebock/ansible-generator) to regenerate all dynamic content. + +If you don't do it, I'll do it later for you. + +### [6. Make a pull request](#6-make-a-pull-request) + +[GitHub](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) on pull requests. + +In the comment-box, you can [refer to the issue number](https://help.github.com/en/github/writing-on-github/autolinked-references-and-urls) by using #123, where 123 is the issue number. + +### [7. Wait](#7-wait) + +Now I'll get a message that you've added some code. Thank you, really. + +CI starts to test your changes. You can follow the progress on Travis. + +Please consider [sponsoring me](https://github.com/sponsors/adfinis). diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b4bbfc3 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2023 Robert de Bock (robert.debock@adfinis.com) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..cc1d739 --- /dev/null +++ b/README.md @@ -0,0 +1,105 @@ +# Ansible role [bareos_console](#bareos_console) + +Install and configure [Bareos](https://www.bareos.com/) Console (bconsole) on your system. + +|GitHub|GitLab|Downloads|Version| +|------|------|---------|-------| +|[![github](https://github.com/adfinis/ansible-role-bareos_console/workflows/Ansible%20Molecule/badge.svg)](https://github.com/adfinis/ansible-role-bareos_console/actions)|[![gitlab](https://gitlab.com/robertdebock-iac/ansible-role-bareos_console/badges/master/pipeline.svg)](https://gitlab.com/robertdebock-iac/ansible-role-bareos_console)|[![downloads](https://img.shields.io/ansible/role/d/)](https://galaxy.ansible.com/adfinis/bareos_console)|[![Version](https://img.shields.io/github/release/adfinis/ansible-role-bareos_console.svg)](https://github.com/adfinis/ansible-role-bareos_console/releases/)| + +## [Example Playbook](#example-playbook) + +This example is taken from [`molecule/default/converge.yml`](https://github.com/adfinis/ansible-role-bareos_console/blob/master/molecule/default/converge.yml) and is tested on each push, pull request and release. + +```yaml +--- +- name: Converge + hosts: all + become: yes + gather_facts: yes + + roles: + - role: adfinis.bareos_console + bareos_console_directors: + - name: bareos-dir + address: localhost + password: "MySuperSecretPassword" + description: "Bareos Console credentials for local Director" + tls_enable: yes + tls_verify_peer: no +``` + +The machine needs to be prepared. In CI this is done using [`molecule/default/prepare.yml`](https://github.com/adfinis/ansible-role-bareos_console/blob/master/molecule/default/prepare.yml): + +```yaml +--- +- name: Prepare + hosts: all + become: yes + gather_facts: no + + roles: + - role: robertdebock.bootstrap + - role: adfinis.bareos_repository +``` + +These roles are provided as is, without warranty of any kind. Use it at your own risk. + +## [Role Variables](#role-variables) + +The default values for the variables are set in [`defaults/main.yml`](https://github.com/adfinis/ansible-role-bareos_console/blob/master/defaults/main.yml): + +```yaml +--- +# defaults file for bareos_console + +bareos_console_directors: [] +``` + +## [Requirements](#requirements) + +- pip packages listed in [requirements.txt](https://github.com/adfinis/ansible-role-bareos_console/blob/master/requirements.txt). + +## [State of used roles](#state-of-used-roles) + +The following roles are used to prepare a system. You can prepare your system in another way. + +| Requirement | GitHub | GitLab | +|-------------|--------|--------| +|[robertdebock.bootstrap](https://galaxy.ansible.com/adfinis/robertdebock.bootstrap)|[![Build Status GitHub](https://github.com/adfinis/robertdebock.bootstrap/workflows/Ansible%20Molecule/badge.svg)](https://github.com/adfinis/robertdebock.bootstrap/actions)|[![Build Status GitLab](https://gitlab.com/robertdebock-iac/robertdebock.bootstrap/badges/master/pipeline.svg)](https://gitlab.com/robertdebock-iac/robertdebock.bootstrap)| +|[adfinis.bareos_repository](https://galaxy.ansible.com/adfinis/bareos_repository)|[![Build Status GitHub](https://github.com/adfinis/ansible-role-bareos_repository/workflows/Ansible%20Molecule/badge.svg)](https://github.com/adfinis/ansible-role-bareos_repository/actions)|[![Build Status GitLab](https://gitlab.com/robertdebock-iac/ansible-role-bareos_repository/badges/master/pipeline.svg)](https://gitlab.com/robertdebock-iac/ansible-role-bareos_repository)| + +## [Context](#context) + +This role is a part of many compatible roles. Have a look at [the documentation of these roles](https://adfinis.com/) for further information. + +Here is an overview of related roles: +![dependencies](https://raw.githubusercontent.com/adfinis/ansible-role-bareos_console/png/requirements.png "Dependencies") + +## [Compatibility](#compatibility) + +This role has been tested on these [container images](https://hub.docker.com/u/robertdebock): + +|container|tags| +|---------|----| +|[Debian](https://hub.docker.com/r/robertdebock/debian)|bookworm, bullseye, buster| +|[EL](https://hub.docker.com/r/robertdebock/enterpriselinux)|7, 8, 9| +|[Fedora](https://hub.docker.com/r/robertdebock/fedora/)|37, 38| +|[opensuse](https://hub.docker.com/r/robertdebock/opensuse)|all| +|[Ubuntu](https://hub.docker.com/r/robertdebock/ubuntu)|jammy, focal| + +The minimum version of Ansible required is 2.12, tests have been done to: + +- The previous version. +- The current version. +- The development version. + +If you find issues, please register them in [GitHub](https://github.com/adfinis/ansible-role-bareos_console/issues). + +## [License](#license) + +[Apache-2.0](https://github.com/adfinis/ansible-role-bareos_console/blob/master/LICENSE). + +## [Author Information](#author-information) + +[robertdebock](https://adfinis.com/) + diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..d3d99ec --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,23 @@ +# [Security Policy](#security-policy) + +This software implements other software, it's not very likely that this software introduces new vulnerabilities. + +## [Supported Versions](#supported-versions) + +These version of [ansible](https://pypi.org/project/ansible/) are supported: + +| Version | Supported | +| ------- | ------------------ | +| 7 | :white_check_mark: | +| 6 | :white_check_mark: | +| 5 | :white_check_mark: | + +## [Reporting a Vulnerability](#reporting-a-vulnarability) + +Please [open an issue](https://github.com/adfinis/ansible-role-bareos_console/issues) describing the vulnerability. + +Tell them where to go, how often they can expect to get an update on a +reported vulnerability, what to expect if the vulnerability is accepted or +declined, etc. + +Please consider [sponsoring me](https://github.com/sponsors/adfinis). diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..fc4bcaf --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,4 @@ +--- +# defaults file for bareos_console + +bareos_console_directors: [] diff --git a/meta/argument_specs.yml b/meta/argument_specs.yml new file mode 100644 index 0000000..4f47424 --- /dev/null +++ b/meta/argument_specs.yml @@ -0,0 +1,14 @@ +--- + +# # bareos_dir_messages: Daemon + +argument_specs: + main: + short_description: "Install and configure BareOS Console (bconsole) on your system." + description: > + Install and configure BareOS Console (bconsole) on your system. + author: Robert de Bock + options: + bareos_console_directors: + type: "list" + description: "A list of directors to connect to." diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..3a70ba2 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,42 @@ +--- +galaxy_info: + author: robertdebock + role_name: bareos_console + description: Install and configure [Bareos](https://www.bareos.com/) Console (bconsole) on your system. + license: Apache-2.0 + company: none + min_ansible_version: "2.12" + + platforms: + - name: Debian + versions: + - bookworm + - bullseye + - buster + - name: EL + versions: + - "7" + - "8" + - "9" + - name: Fedora + versions: + - "37" + - "38" + - name: opensuse + versions: + - all + - name: Ubuntu + versions: + - jammy + - focal + + galaxy_tags: + - backup + - bareos + - infrastructure + - linux + - storage + - system + - tools + +dependencies: [] diff --git a/molecule/default/collections.yml b/molecule/default/collections.yml new file mode 100644 index 0000000..b869f41 --- /dev/null +++ b/molecule/default/collections.yml @@ -0,0 +1,4 @@ +--- +collections: + - name: community.docker + - name: community.general diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml new file mode 100644 index 0000000..3461711 --- /dev/null +++ b/molecule/default/converge.yml @@ -0,0 +1,15 @@ +--- +- name: Converge + hosts: all + become: yes + gather_facts: yes + + roles: + - role: ansible-role-bareos_console + bareos_console_directors: + - name: bareos-dir + address: localhost + password: "MySuperSecretPassword" + description: "Bareos Console credentials for local Director" + tls_enable: yes + tls_verify_peer: no diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 0000000..3a766f7 --- /dev/null +++ b/molecule/default/molecule.yml @@ -0,0 +1,27 @@ +--- +# +# Ansible managed +# +dependency: + name: galaxy + options: + role-file: requirements.yml + requirements-file: requirements.yml +lint: | + set -e + yamllint . + ansible-lint +driver: + name: docker +platforms: + - name: "bareosconsole-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" + image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" + command: /sbin/init + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes + pre_build_image: yes +provisioner: + name: ansible +verifier: + name: ansible diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml new file mode 100644 index 0000000..2099bfd --- /dev/null +++ b/molecule/default/prepare.yml @@ -0,0 +1,9 @@ +--- +- name: Prepare + hosts: all + become: yes + gather_facts: no + + roles: + - role: robertdebock.bootstrap + - role: adfinis.bareos_repository diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml new file mode 100644 index 0000000..413f036 --- /dev/null +++ b/molecule/default/verify.yml @@ -0,0 +1,16 @@ +--- +- name: Verify + hosts: all + become: yes + gather_facts: no + + tasks: + - name: Run bconsole --version + ansible.builtin.command: + cmd: bconsole --version + changed_when: no + + - name: List directors + ansible.builtin.command: + cmd: bconsole --list-directors + changed_when: no diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..dba7154 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +# Pinning ansible-compat version due to [bug](https://github.com/ansible-community/molecule/issues/3903) +ansible-compat == 3.0.2 +molecule == 5.* +molecule-plugins[docker] == 23.* +ansible-lint == 6.* +paramiko == 3.* diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..bcfbda7 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,4 @@ +--- +roles: + - name: robertdebock.bootstrap + - name: adfinis.bareos_repository diff --git a/tasks/assert.yml b/tasks/assert.yml new file mode 100644 index 0000000..30c8b5a --- /dev/null +++ b/tasks/assert.yml @@ -0,0 +1,53 @@ +--- + +- name: assert | Test bareos_console_directors + ansible.builtin.assert: + that: + - bareos_console_directors is iterable + quiet: yes + when: + - bareos_console_directors is defined + +- name: assert | Test items in bareos_console_directors are set correctly + ansible.builtin.assert: + that: + - item.name is defined + - item.name is string + - item.name != "" + - item.address is defined + - item.address is string + - item.address != "" + - item.password is defined + - item.password is string + - item.password != "" + - item.description is defined + - item.description is string + - item.description != "" + quiet: yes + loop: "{{ bareos_console_directors }}" + loop_control: + label: "{{ item.name }}" + when: + - bareos_console_directors is defined + +- name: assert | Test item tls_enable in bareos_console_directors + ansible.builtin.assert: + that: + - item.tls_enable is boolean + quiet: yes + loop: "{{ bareos_console_directors }}" + loop_control: + label: "{{ item.name }}" + when: + - item.tls_enable is defined + +- name: assert | Test item tls_verify_peer in bareos_console_directors + ansible.builtin.assert: + that: + - item.tls_verify_peer is boolean + quiet: yes + loop: "{{ bareos_console_directors }}" + loop_control: + label: "{{ item.name }}" + when: + - item.tls_verify_peer is defined diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..3e84827 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,24 @@ +--- +# tasks file for bareos_console + +- name: Import assert.yml + ansible.builtin.import_tasks: + file: assert.yml + run_once: yes + delegate_to: localhost + +- name: Install bareos-console + ansible.builtin.package: + name: bareos-bconsole + state: present + +- name: Place bconsole.conf + ansible.builtin.template: + src: bconsole.conf.j2 + dest: /etc/bareos/bconsole.conf + owner: root + group: bareos + mode: "0640" + validate: /usr/sbin/bconsole --test-config --config %s + when: + - bareos_console_directors is defined diff --git a/templates/.gitkeep b/templates/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/templates/bconsole.conf.j2 b/templates/bconsole.conf.j2 new file mode 100644 index 0000000..3a3c77d --- /dev/null +++ b/templates/bconsole.conf.j2 @@ -0,0 +1,24 @@ +{{ ansible_managed | comment }} + +{% if bareos_console_directors is defined %} +{% for director in bareos_console_directors %} +Director { + Name = "{{ director.name }}" +{% if director.description is defined %} + Description = "{{ director.description }}" +{% endif %} +{% if director.address is defined %} + Address = "{{ director.address }}" +{% endif %} +{% if director.password is defined %} + Password = "[md5]{{ director.password | md5 }}" +{% endif %} +{% if director.tls_enable is defined %} + TLS Enable = {{ director.tls_enable | ternary('Yes', 'No') }} +{% endif %} +{% if director.tls_verify_peer is defined %} + TLS Verify Peer = {{ director.tls_verify_peer | ternary('Yes', 'No') }} +{% endif %} +} +{% endfor %} +{% endif %} diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..699c9eb --- /dev/null +++ b/tox.ini @@ -0,0 +1,27 @@ +# +# Ansible managed +# +[tox] +minversion = 4.2.4 +envlist = py3-ansible{6,7,8} + +skipsdist = true + +[testenv] +deps = + -rrequirements.txt + ansible6: ansible == 6.* + ansible7: ansible == 7.* + ansible8: ansible == 8.* +commands = molecule test +setenv = + TOX_ENVNAME={envname} + PY_COLORS=1 + ANSIBLE_FORCE_COLOR=1 + ANSIBLE_ROLES_PATH=../ + +passenv = + namespace + image + tag + DOCKER_HOST