From 6891cd118c542afd33cfea1baa49c5ab7412e22b Mon Sep 17 00:00:00 2001 From: Robert de Bock Date: Fri, 24 Nov 2023 12:41:07 +0100 Subject: [PATCH] Initial commit. --- .ansible-lint | 19 ++ .github/FUNDING.yml | 2 + .github/ISSUE_TEMPLATE/bug_report.md | 30 ++++ .github/ISSUE_TEMPLATE/feature_request.md | 18 ++ .github/settings.yml | 8 + .github/workflows/galaxy.yml | 18 ++ .github/workflows/molecule.yml | 67 +++++++ .github/workflows/requirements2png.yml | 35 ++++ .github/workflows/todo.yml | 20 +++ .gitignore | 6 + .gitlab-ci.yml | 42 +++++ .pre-commit-config.yaml | 25 +++ .yamllint | 16 ++ CODE_OF_CONDUCT.md | 46 +++++ CONTRIBUTING.md | 76 ++++++++ LICENSE | 202 ++++++++++++++++++++++ README.md | 183 ++++++++++++++++++++ SECURITY.md | 23 +++ defaults/main.yml | 37 ++++ handlers/main.yml | 11 ++ meta/argument_specs.yml | 53 ++++++ meta/main.yml | 41 +++++ molecule/default/collections.yml | 4 + molecule/default/converge.yml | 59 +++++++ molecule/default/molecule.yml | 27 +++ molecule/default/prepare.yml | 10 ++ molecule/default/verify.yml | 18 ++ requirements.txt | 6 + requirements.yml | 4 + tasks/assert.yml | 87 ++++++++++ tasks/main.yml | 111 ++++++++++++ templates/.gitkeep | 0 templates/bareos-sd.conf.j2 | 15 ++ templates/device.conf.j2 | 28 +++ templates/director.conf.j2 | 16 ++ templates/message.conf.j2 | 19 ++ templates/s3.profile.j2 | 10 ++ tox.ini | 27 +++ vars/main.yml | 19 ++ 39 files changed, 1438 insertions(+) create mode 100644 .ansible-lint create mode 100644 .github/FUNDING.yml create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/settings.yml create mode 100644 .github/workflows/galaxy.yml create mode 100644 .github/workflows/molecule.yml create mode 100644 .github/workflows/requirements2png.yml create mode 100644 .github/workflows/todo.yml create mode 100644 .gitignore create mode 100644 .gitlab-ci.yml create mode 100644 .pre-commit-config.yaml create mode 100644 .yamllint create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 SECURITY.md create mode 100644 defaults/main.yml create mode 100644 handlers/main.yml create mode 100644 meta/argument_specs.yml create mode 100644 meta/main.yml create mode 100644 molecule/default/collections.yml create mode 100644 molecule/default/converge.yml create mode 100644 molecule/default/molecule.yml create mode 100644 molecule/default/prepare.yml create mode 100644 molecule/default/verify.yml create mode 100644 requirements.txt create mode 100644 requirements.yml create mode 100644 tasks/assert.yml create mode 100644 tasks/main.yml create mode 100644 templates/.gitkeep create mode 100644 templates/bareos-sd.conf.j2 create mode 100644 templates/device.conf.j2 create mode 100644 templates/director.conf.j2 create mode 100644 templates/message.conf.j2 create mode 100644 templates/s3.profile.j2 create mode 100644 tox.ini create mode 100644 vars/main.yml 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..84d6980 --- /dev/null +++ b/.github/settings.yml @@ -0,0 +1,8 @@ +--- +# +# Ansible managed +# +repository: + description: Install and configure [Bareos](https://www.bareos.com/) Storage Daemon. + homepage: https://adfinis.com/ + topics: 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..78f3d28 --- /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_sd/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_sd), 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_sd.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..59bb316 --- /dev/null +++ b/README.md @@ -0,0 +1,183 @@ +# Ansible role [bareos_sd](#bareos_sd) + +Install and configure [Bareos](https://www.bareos.com/) Storage Daemon. + +|GitHub|GitLab|Downloads|Version| +|------|------|---------|-------| +|[![github](https://github.com/adfinis/ansible-role-bareos_sd/workflows/Ansible%20Molecule/badge.svg)](https://github.com/adfinis/ansible-role-bareos_sd/actions)|[![gitlab](https://gitlab.com/robertdebock-iac/ansible-role-bareos_sd/badges/master/pipeline.svg)](https://gitlab.com/robertdebock-iac/ansible-role-bareos_sd)|[![downloads](https://img.shields.io/ansible/role/d/)](https://galaxy.ansible.com/adfinis/bareos_sd)|[![Version](https://img.shields.io/github/release/adfinis/ansible-role-bareos_sd.svg)](https://github.com/adfinis/ansible-role-bareos_sd/releases/)| + +## [Example Playbook](#example-playbook) + +This example is taken from [`molecule/default/converge.yml`](https://github.com/adfinis/ansible-role-bareos_sd/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_sd + bareos_sd_backup_configurations: yes + bareos_sd_install_debug_packages: yes + bareos_sd_devices: + - name: "FileStorage" + description: "File device. A connecting Director must have the same Name and MediaType." + media_type: "File" + archive_device: "/var/lib/bareos/storage" + label_media: yes + random_access: yes + automatic_mount: yes + removable_media: no + always_open: no + maximum_concurrent_jobs: 1 + - name: "disabled-device" + enabled: no + bareos_sd_directors: + - name: bareos-dir + password: "somepassword" + - name: "disabled-director" + enabled: no + bareos_sd_messages: + - name: "Standard" + description: "Send relevant messages to the Director." + director: + server: bareos-dir + messages: + - all + - "!skipped" + - "!restored" + append: + file: "/var/log/bareos/bareos.log" + messages: + - all + - "!skipped" + - "!terminate" + console: + - all + - "!skipped" + - "!saved" + - name: "disabled-message" + enabled: no + bareos_sd_s3_profiles: + - name: exoscale + host: "sos.exo.io:443" + use_https: yes + access_key: "SomeAPIKey" + secret_key: "SomeSecret" + pricing_dir: "" + backend: "s3" + aws_auth_sign_version: 4 + aws_region: "ch-gva-2" +``` + +The machine needs to be prepared. In CI this is done using [`molecule/default/prepare.yml`](https://github.com/adfinis/ansible-role-bareos_sd/blob/master/molecule/default/prepare.yml): + +```yaml +--- +- name: Prepare + hosts: all + become: yes + gather_facts: no + + roles: + - role: robertdebock.bootstrap + - role: adfinis.bareos_repository + bareos_repository_enable_tracebacks: yes +``` + +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_sd/blob/master/defaults/main.yml): + +```yaml +--- +# defaults file for bareos_sd + +# The Storage Daemon has these configuration parameters. + +# Backup the configuration files. +bareos_sd_backup_configurations: no + +# Install debug packages. This requires the debug repositories to be enabled. +bareos_sd_install_debug_packages: no + +# The hostname of the Storage Daemon. +bareos_sd_hostname: "{{ inventory_hostname }}" + +# The messages configuration to use. +bareos_sd_message: "Standard" + +# The amount of jobs to run concurrently. +bareos_sd_max_concurrent_jobs: 20 + +# Enable TLS. +bareos_sd_tls_enable: yes + +# Verify the peer. +bareos_sd_tls_verify_peer: no + +# A list of devices to configure. +bareos_sd_devices: [] + +# A list of directors to connect to. +bareos_sd_directors: [] + +# A list of messages to send to the director. +bareos_sd_messages: [] + +# A list of S3 profiles to configure. +bareos_sd_s3_profiles: [] +``` + +## [Requirements](#requirements) + +- pip packages listed in [requirements.txt](https://github.com/adfinis/ansible-role-bareos_sd/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_sd/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_sd/issues). + +## [License](#license) + +[Apache-2.0](https://github.com/adfinis/ansible-role-bareos_sd/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..81dccb4 --- /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_sd/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..eaf653c --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,37 @@ +--- +# defaults file for bareos_sd + +# The Storage Daemon has these configuration parameters. + +# Backup the configuration files. +bareos_sd_backup_configurations: no + +# Install debug packages. This requires the debug repositories to be enabled. +bareos_sd_install_debug_packages: no + +# The hostname of the Storage Daemon. +bareos_sd_hostname: "{{ inventory_hostname }}" + +# The messages configuration to use. +bareos_sd_message: "Standard" + +# The amount of jobs to run concurrently. +bareos_sd_max_concurrent_jobs: 20 + +# Enable TLS. +bareos_sd_tls_enable: yes + +# Verify the peer. +bareos_sd_tls_verify_peer: no + +# A list of devices to configure. +bareos_sd_devices: [] + +# A list of directors to connect to. +bareos_sd_directors: [] + +# A list of messages to send to the director. +bareos_sd_messages: [] + +# A list of S3 profiles to configure. +bareos_sd_s3_profiles: [] diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..a026a61 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,11 @@ +--- +# handlers file for bareos_sd + +- name: Check configuration + ansible.builtin.command: "/usr/sbin/bareos-sd --test-config" + changed_when: false + +- name: Restart bareos-sd + ansible.builtin.service: + name: bareos-sd + state: restarted diff --git a/meta/argument_specs.yml b/meta/argument_specs.yml new file mode 100644 index 0000000..e00bebc --- /dev/null +++ b/meta/argument_specs.yml @@ -0,0 +1,53 @@ +--- + +argument_specs: + main: + short_description: "Install and configure BareOS Storage Daemon on your system." + description: > + Install and configure BareOS Storage Daemon on your system. + author: Robert de Bock + options: + bareos_sd_backup_configurations: + type: "bool" + default: no + description: "Backup the configuration files." + bareos_sd_hostname: + type: "str" + default: "{{ inventory_hostname }}" + description: "The hostname of the Storage Daemon." + bareos_sd_message: + type: "str" + default: "Standard" + description: "The messages configuration to use." + bareos_sd_max_concurrent_jobs: + type: "int" + default: 20 + description: "The amount of jobs to run concurrently." + bareos_sd_tls_enable: + type: "bool" + default: yes + description: "Enable TLS." + bareos_sd_tls_verify_peer: + type: "bool" + default: no + description: "Verify the peer." + bareos_sd_devices: + type: "list" + default: [] + description: "A list of devices to configure." + bareos_sd_directors: + type: "list" + default: [] + description: "A list of directors to connect to." + bareos_sd_messages: + type: "list" + default: [] + description: "A list of messages to send to the director." + bareos_sd_s3_profiles: + type: "list" + default: [] + description: "A list of S3 profiles to configure." + bareos_sd_install_debug_packages: + type: "bool" + default: no + description: "Install debug packages. This requires the debug repositories to be enabled." diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..fdb918f --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,41 @@ +--- +galaxy_info: + author: robertdebock + role_name: bareos_sd + description: Install and configure [Bareos](https://www.bareos.com/) Storage Daemon. + 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: + - 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..851eaf1 --- /dev/null +++ b/molecule/default/converge.yml @@ -0,0 +1,59 @@ +--- +- name: Converge + hosts: all + become: yes + gather_facts: yes + + roles: + - role: ansible-role-bareos_sd + bareos_sd_backup_configurations: yes + bareos_sd_install_debug_packages: yes + bareos_sd_devices: + - name: "FileStorage" + description: "File device. A connecting Director must have the same Name and MediaType." + media_type: "File" + archive_device: "/var/lib/bareos/storage" + label_media: yes + random_access: yes + automatic_mount: yes + removable_media: no + always_open: no + maximum_concurrent_jobs: 1 + - name: "disabled-device" + enabled: no + bareos_sd_directors: + - name: bareos-dir + password: "somepassword" + - name: "disabled-director" + enabled: no + bareos_sd_messages: + - name: "Standard" + description: "Send relevant messages to the Director." + director: + server: bareos-dir + messages: + - all + - "!skipped" + - "!restored" + append: + file: "/var/log/bareos/bareos.log" + messages: + - all + - "!skipped" + - "!terminate" + console: + - all + - "!skipped" + - "!saved" + - name: "disabled-message" + enabled: no + bareos_sd_s3_profiles: + - name: exoscale + host: "sos.exo.io:443" + use_https: yes + access_key: "SomeAPIKey" + secret_key: "SomeSecret" + pricing_dir: "" + backend: "s3" + aws_auth_sign_version: 4 + aws_region: "ch-gva-2" diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 0000000..431694d --- /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: "bareossd-${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..c980188 --- /dev/null +++ b/molecule/default/prepare.yml @@ -0,0 +1,10 @@ +--- +- name: Prepare + hosts: all + become: yes + gather_facts: no + + roles: + - role: robertdebock.bootstrap + - role: adfinis.bareos_repository + bareos_repository_enable_tracebacks: yes diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml new file mode 100644 index 0000000..188c020 --- /dev/null +++ b/molecule/default/verify.yml @@ -0,0 +1,18 @@ +--- +- name: Verify + hosts: all + become: yes + gather_facts: no + + tasks: + - name: Check if port 9103 is listening + ansible.builtin.wait_for: + port: 9103 + + - name: Test configuration for warnings + ansible.builtin.command: + cmd: bareos-sd --test-config + become_user: bareos + register: bareos_sd_test_config + failed_when: + - bareos_sd_test_config.stdout_lines is search("There are configuration warnings") 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..8658810 --- /dev/null +++ b/tasks/assert.yml @@ -0,0 +1,87 @@ +--- + +- name: assert | Test bareos_sd_backup_configurations + ansible.builtin.assert: + that: + - bareos_sd_backup_configurations is defined + - bareos_sd_backup_configurations is boolean + quiet: yes + +- name: assert | Test bareos_sd_install_debug_packages + ansible.builtin.assert: + that: + - bareos_sd_install_debug_packages is defined + - bareos_sd_install_debug_packages is boolean + quiet: yes + +- name: assert | Test bareos_sd_hostname + ansible.builtin.assert: + that: + - bareos_sd_hostname is defined + - bareos_sd_hostname is string + - bareos_sd_hostname is not none + quiet: yes + +- name: assert | Test bareos_sd_message + ansible.builtin.assert: + that: + - bareos_sd_message is defined + - bareos_sd_message is string + - bareos_sd_message is not none + quiet: yes + +- name: assert | Test bareos_sd_max_concurrent_jobs + ansible.builtin.assert: + that: + - bareos_sd_max_concurrent_jobs is defined + - bareos_sd_max_concurrent_jobs is number + quiet: yes + +- name: assert | Test bareos_sd_tls_enable + ansible.builtin.assert: + that: + - bareos_sd_tls_enable is defined + - bareos_sd_tls_enable is boolean + quiet: yes + +- name: assert | Test bareos_sd_tls_verify_peer + ansible.builtin.assert: + that: + - bareos_sd_tls_verify_peer is defined + - bareos_sd_tls_verify_peer is boolean + quiet: yes + +- name: assert | Test bareos_sd_directors + ansible.builtin.assert: + that: + - bareos_sd_directors is defined + - bareos_sd_directors is iterable + quiet: yes + +- name: assert | Test bareos_sd_devices + ansible.builtin.assert: + that: + - bareos_sd_devices is defined + - bareos_sd_devices is iterable + quiet: yes + +- name: assert | Test bareos_sd_directors + ansible.builtin.assert: + that: + - bareos_sd_directors is defined + - bareos_sd_directors is iterable + quiet: yes + +- name: assert | Test bareos_sd_messages + ansible.builtin.assert: + that: + - bareos_sd_messages is defined + - bareos_sd_messages is iterable + quiet: yes + +- name: assert | Test bareos_sd_s3_profiles + ansible.builtin.assert: + that: + - bareos_sd_s3_profiles is defined + - bareos_sd_s3_profiles is iterable + quiet: yes diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..97508a3 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,111 @@ +--- +# tasks file for bareos_sd + +- name: Import assert.yml + ansible.builtin.import_tasks: + file: assert.yml + run_once: yes + delegate_to: localhost + +- name: Install packages + ansible.builtin.package: + name: "{{ bareos_sd_packages }}" + +- name: Install debug packages + ansible.builtin.package: + name: "{{ bareos_sd_debug_packages }}" + when: + - bareos_sd_install_debug_packages + +- name: Place bareos-sd.conf + ansible.builtin.template: + src: bareos-sd.conf.j2 + dest: "/etc/bareos/bareos-sd.d/storage/bareos-sd.conf" + owner: bareos + group: bareos + mode: "0640" + backup: "{{ bareos_sd_backup_configurations }}" + notify: + - Check configuration + - Restart bareos-sd + +- name: Place device + ansible.builtin.template: + src: device.conf.j2 + dest: "/etc/bareos/bareos-sd.d/device/{{ item.name }}.conf" + owner: bareos + group: bareos + mode: "0640" + backup: "{{ bareos_sd_backup_configurations }}" + loop: "{{ bareos_sd_devices }}" + loop_control: + label: "{{ item.name }}" + notify: + - Check configuration + - Restart bareos-sd + +- name: Place director + ansible.builtin.template: + src: director.conf.j2 + dest: "/etc/bareos/bareos-sd.d/director/{{ item.name }}.conf" + owner: bareos + group: bareos + mode: "0640" + backup: "{{ bareos_sd_backup_configurations }}" + loop: "{{ bareos_sd_directors }}" + loop_control: + label: "{{ item.name }}" + notify: + - Check configuration + - Restart bareos-sd + +- name: Place message + ansible.builtin.template: + src: message.conf.j2 + dest: "/etc/bareos/bareos-sd.d/messages/{{ item.name }}.conf" + owner: bareos + group: bareos + mode: "0640" + backup: "{{ bareos_sd_backup_configurations }}" + loop: "{{ bareos_sd_messages }}" + loop_control: + label: "{{ item.name }}" + notify: + - Check configuration + - Restart bareos-sd + +- name: Install bareos-storage-droplet. + ansible.builtin.package: + name: bareos-storage-droplet + when: + - bareos_sd_s3_profiles | length > 0 + +- name: Create /etc/bareos/bareos-sd.d/device/droplet + ansible.builtin.file: + path: /etc/bareos/bareos-sd.d/device/droplet + state: directory + owner: bareos + group: bareos + mode: "0755" + when: + - bareos_sd_s3_profiles | length > 0 + +- name: Place S3 profile + ansible.builtin.template: + src: s3.profile.j2 + dest: /etc/bareos/bareos-sd.d/device/droplet/{{ item.name }}.profile + owner: bareos + group: bareos + mode: "0600" + loop: "{{ bareos_sd_s3_profiles }}" + loop_control: + label: "{{ item.name }}" + notify: + - Check configuration + - Restart bareos-sd + +- name: Start bareos-sd + ansible.builtin.service: + name: bareos-sd + state: started + enabled: yes diff --git a/templates/.gitkeep b/templates/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/templates/bareos-sd.conf.j2 b/templates/bareos-sd.conf.j2 new file mode 100644 index 0000000..f1ae704 --- /dev/null +++ b/templates/bareos-sd.conf.j2 @@ -0,0 +1,15 @@ +{{ ansible_managed | comment }} + +Storage { + Name = "{{ bareos_sd_hostname }}" + Messages = "{{ bareos_sd_message }}" +{% if bareos_sd_max_concurrent_jobs != 20 %} + Maximum Concurrent Jobs = {{ bareos_sd_max_concurrent_jobs }} +{% endif %} +{% if not bareos_sd_tls_enable %} + TLS Enable = No +{% endif %} +{% if bareos_sd_tls_verify_peer %} + TLS Verify Peer = Yes +{% endif %} +} diff --git a/templates/device.conf.j2 b/templates/device.conf.j2 new file mode 100644 index 0000000..990287e --- /dev/null +++ b/templates/device.conf.j2 @@ -0,0 +1,28 @@ +{{ ansible_managed | comment }} + +{% if item.enabled is defined and item.enabled or item.enabled is not defined %} +Device { + Name = "{{ item.name }}" +{% if item.description is defined %} + Description = "{{ item.description }}" +{% endif %} +{% if item.maximum_concurrent_jobs is defined %} + Maximum Concurrent Jobs = {{ item.maximum_concurrent_jobs }} +{% endif %} + Media Type = "{{ item.media_type }}" + Archive Device = "{{ item.archive_device }}" +{% if item.device_type is defined %} + Device Type = "{{ item.device_type }}" +{% endif %} +{% if item.device_options is defined %} + Device Options = "{{ item.device_options }}" +{% endif %} + LabelMedia = {{ item.label_media | ternary('yes', 'No') }} + Random Access = {{ item.random_access | ternary('yes', 'No') }} + AutomaticMount = {{ item.automatic_mount | ternary('yes', 'No') }} + RemovableMedia = {{ item.removable_media | ternary('yes', 'No') }} + AlwaysOpen = {{ item.always_open | ternary('yes', 'No') }} +} +{% else %} +# This file is not enabled. +{% endif %} diff --git a/templates/director.conf.j2 b/templates/director.conf.j2 new file mode 100644 index 0000000..6a1be4c --- /dev/null +++ b/templates/director.conf.j2 @@ -0,0 +1,16 @@ +{{ ansible_managed | comment }} + +{% if item.enabled is defined and item.enabled or item.enabled is not defined %} +Director { + Name = "{{ item.name }}" + Password = "{{ item.password }}" +{% if item.tls_enable is defined %} + TLS Enable = {{ item.tls_enable | ternary('Yes', 'No') }} +{% endif %} +{% if item.tls_verify_peer is defined %} + TLS Verify Peer = {{ item.tls_verify_peer | ternary('Yes', 'No') }} +{% endif %} +} +{% else %} +# This file is not enabled. +{% endif %} diff --git a/templates/message.conf.j2 b/templates/message.conf.j2 new file mode 100644 index 0000000..baebbf2 --- /dev/null +++ b/templates/message.conf.j2 @@ -0,0 +1,19 @@ +{{ ansible_managed | comment }} + +{% if item.enabled is defined and item.enabled or item.enabled is not defined %} +Messages { + Name = "{{ item.name }}" + Description = "{{ item.description }}" +{% if item.director is defined %} + Director = {{ item.director.server }} = {{ item.director.messages | join(', ') }} +{% endif %} +{% if item.append is defined %} + Append = "{{ item.append.file }}" = {{ item.append.messages | join(', ') }} +{% endif %} +{% if item.console is defined %} + Console = {{ item.console | join(', ') }} +{% endif %} +} +{% else %} +# This file is not enabled. +{% endif %} diff --git a/templates/s3.profile.j2 b/templates/s3.profile.j2 new file mode 100644 index 0000000..c5a2b63 --- /dev/null +++ b/templates/s3.profile.j2 @@ -0,0 +1,10 @@ +{{ ansible_managed | comment }} + +host = "{{ item.host }}" +use_https = {{ item.use_https | ternary("true", "false") }} +access_key = {{ item.access_key }} +secret_key = {{ item.secret_key }} +pricing_dir = "{{ item.pricing_dir }}" +backend = {{ item.backend }} +aws_auth_sign_version = {{ item.aws_auth_sign_version }} +aws_region = {{ item.aws_region }} 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 diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..c577c38 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,19 @@ +--- +# vars file for bareos_sd + +bareos_sd_packages: + - bareos-storage + - bareos-storage-tape + +# A map to define the packages to install for debugging. +_bareos_sd_debug_packages: + default: + - bareos-storage-debuginfo + - gdb + Debian: + - bareos-dbg + - gdb + RedHat-7: + - bareos-debuginfo + - gdb +bareos_sd_debug_packages: "{{ _bareos_sd_debug_packages[ansible_os_family ~ '-' ~ ansible_distribution_major_version] | default(_bareos_sd_debug_packages[ansible_os_family] | default(_bareos_sd_debug_packages['default'])) }}"