├── .ansible-lint-ignore ├── .circleci └── config.yml ├── .flake8 ├── .gitattributes ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── CODE_OF_CONDUCT.md ├── COPYING ├── Makefile ├── README.md ├── changelogs └── changelog.yaml ├── collection.requirements ├── docker ├── alma-8.docker ├── amazon-1.docker ├── amazon-2.docker ├── build-all.sh ├── build.sh ├── centos-6.docker ├── centos-7.docker ├── centos-8.docker ├── debian-10.docker ├── debian-9.docker ├── oracle-8.docker ├── redhat-7.docker ├── rocky-8.docker ├── sensu-5.14.2.docker ├── sensu-5.21.3.docker ├── sensu-6.10.0.docker ├── sensu-6.2.5.docker ├── sensu-6.3.0.docker ├── sensu-6.4.3.docker ├── sensu-6.5.5.docker ├── sensu-6.6.2.docker ├── sensu-6.7.5.docker ├── sensu-6.8.2.docker ├── sensu-6.9.0.docker ├── ubuntu-14.04.docker ├── ubuntu-16.04.docker ├── ubuntu-18.04.docker ├── ubuntu-20.04.docker └── ubuntu-22.04.docker ├── docs.requirements ├── docs ├── Makefile ├── Makefile.custom ├── examples │ ├── installation │ │ └── ansible.cfg │ ├── quickstart │ │ ├── inventory.yaml │ │ ├── playbook-5.yaml │ │ └── playbook-6.yaml │ └── roles │ │ ├── agent.yaml │ │ ├── backend.yaml │ │ └── install.yaml ├── source │ ├── conf.py │ ├── hacking.rst │ ├── hacking │ │ ├── docker-images.rst │ │ ├── documentation.rst │ │ ├── releases.rst │ │ ├── setup.rst │ │ ├── testing.rst │ │ └── windows.rst │ ├── index.rst │ ├── installation.rst │ ├── modules.rst │ ├── quickstart-sensu-go-5.rst │ ├── quickstart-sensu-go-6.rst │ ├── release_notes.rst │ ├── release_policy.rst │ ├── roles.rst │ ├── roles │ │ ├── agent.rst │ │ ├── backend.rst │ │ └── install.rst │ ├── sensu_go_5_6_migration.rst │ └── versioning_sensu_go_installation.rst └── templates │ └── module.rst.j2 ├── galaxy.yml ├── integration.requirements ├── meta ├── execution-environment.yml └── runtime.yml ├── molecule.yml ├── plugins ├── action │ └── bonsai_asset.py ├── doc_fragments │ ├── annotations.py │ ├── auth.py │ ├── info.py │ ├── labels.py │ ├── name.py │ ├── namespace.py │ ├── requirements.py │ ├── secrets.py │ └── state.py ├── filter │ ├── backends.py │ ├── backends.yml │ ├── package_name.py │ └── package_name.yml ├── module_utils │ ├── arguments.py │ ├── bonsai.py │ ├── client.py │ ├── debug.py │ ├── errors.py │ ├── http.py │ ├── role_utils.py │ └── utils.py └── modules │ ├── ad_auth_provider.py │ ├── asset.py │ ├── asset_info.py │ ├── auth_provider_info.py │ ├── bonsai_asset.py │ ├── check.py │ ├── check_info.py │ ├── cluster.py │ ├── cluster_info.py │ ├── cluster_role.py │ ├── cluster_role_binding.py │ ├── cluster_role_binding_info.py │ ├── cluster_role_info.py │ ├── datastore.py │ ├── datastore_info.py │ ├── entity.py │ ├── entity_info.py │ ├── etcd_replicator.py │ ├── etcd_replicator_info.py │ ├── event.py │ ├── event_info.py │ ├── filter.py │ ├── filter_info.py │ ├── handler_info.py │ ├── handler_set.py │ ├── hook.py │ ├── hook_info.py │ ├── ldap_auth_provider.py │ ├── mutator.py │ ├── mutator_info.py │ ├── namespace.py │ ├── namespace_info.py │ ├── oidc_auth_provider.py │ ├── pipe_handler.py │ ├── pipeline.py │ ├── pipeline_info.py │ ├── role.py │ ├── role_binding.py │ ├── role_binding_info.py │ ├── role_info.py │ ├── secret.py │ ├── secret_info.py │ ├── secrets_provider_env.py │ ├── secrets_provider_info.py │ ├── secrets_provider_vault.py │ ├── silence.py │ ├── silence_info.py │ ├── socket_handler.py │ ├── tessen.py │ ├── user.py │ └── user_info.py ├── pytest.ini ├── roles ├── agent │ ├── README.md │ ├── defaults │ │ └── main.yml │ ├── handlers │ │ └── main.yml │ ├── meta │ │ ├── argument_specs.yml │ │ └── main.yml │ ├── tasks │ │ ├── configure.yml │ │ ├── linux │ │ │ └── configure.yml │ │ ├── main.yml │ │ ├── start.yml │ │ └── windows │ │ │ └── configure.yml │ ├── templates │ │ └── agent.yml.j2 │ └── vars │ │ ├── linux.yml │ │ ├── main.yml │ │ └── windows.yml ├── backend │ ├── README.md │ ├── defaults │ │ └── main.yml │ ├── handlers │ │ └── main.yml │ ├── meta │ │ ├── argument_specs.yml │ │ └── main.yml │ ├── tasks │ │ ├── configure.yml │ │ ├── main.yml │ │ └── start.yml │ ├── templates │ │ └── backend.yml.j2 │ └── vars │ │ └── main.yml └── install │ ├── README.md │ ├── defaults │ └── main.yml │ ├── meta │ ├── argument_specs.yml │ └── main.yml │ ├── tasks │ ├── apt │ │ ├── install.yml │ │ └── prepare.yml │ ├── dnf │ │ ├── install.yml │ │ └── prepare.yml │ ├── main.yml │ ├── msi │ │ └── install.yml │ ├── packages.yml │ ├── repositories.yml │ └── yum │ │ ├── install.yml │ │ └── prepare.yml │ └── vars │ ├── Alma.yml │ ├── AlmaLinux.yml │ ├── Amazon.yml │ ├── CentOS.yml │ ├── Debian.yml │ ├── OracleLinux.yml │ ├── RedHat.yml │ ├── Rocky.yml │ ├── Ubuntu.yml │ └── Windows.yml ├── sanity.requirements ├── tests ├── config.yml ├── integration │ ├── base.yml │ └── molecule │ │ ├── action_bonsai_asset │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── misc_api_authentication │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── misc_api_cert │ │ ├── converge.yml │ │ ├── files │ │ │ ├── regenerate_cert.sh │ │ │ ├── sensu-api-ca.crt │ │ │ ├── sensu-api.cnf │ │ │ ├── sensu-api.crt │ │ │ ├── sensu-api.key │ │ │ └── sensu-api.pem │ │ ├── molecule.yml │ │ └── prepare.yml │ │ ├── module_ad_auth_provider │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_asset │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_check │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_cluster │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_cluster_role │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_cluster_role_binding │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_datastore │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_entity │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_etcd_replicator │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_event │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_filter │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_handler_set │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_hook │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_ldap_auth_provider │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_mutator │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_namespace │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_oidc_auth_provider │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_pipe_handler │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_pipeline │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_role │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_role_binding │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_secret │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_secrets_provider_env │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_secrets_provider_vault │ │ ├── converge.yml │ │ ├── files │ │ │ ├── ca.crt │ │ │ ├── client.crt │ │ │ └── client.key │ │ └── molecule.yml │ │ ├── module_silence │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_socket_handler │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_tessen │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── module_user │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── role_agent_config │ │ ├── converge.yml │ │ ├── molecule.yml │ │ └── prepare.yml │ │ ├── role_agent_default │ │ ├── converge.yml │ │ ├── molecule.yml │ │ └── verify.yml │ │ ├── role_agent_secured │ │ ├── converge.yml │ │ ├── files │ │ │ └── sensu-agent-trusted-ca.crt │ │ └── molecule.yml │ │ ├── role_backend_config │ │ ├── converge.yml │ │ ├── molecule.yml │ │ └── prepare.yml │ │ ├── role_backend_default │ │ ├── converge.yml │ │ ├── molecule.yml │ │ └── verify.yml │ │ ├── role_backend_secured │ │ ├── converge.yml │ │ ├── files │ │ │ ├── client-ca.crt │ │ │ ├── etcd-client.crt │ │ │ ├── etcd-client.key │ │ │ ├── etcd-peer-ca.crt │ │ │ ├── etcd-peer.crt │ │ │ ├── etcd-peer.key │ │ │ ├── sensu-api-ca.crt │ │ │ ├── sensu-api.crt │ │ │ ├── sensu-api.key │ │ │ ├── sensu-dashboard.crt │ │ │ └── sensu-dashboard.key │ │ ├── molecule.yml │ │ └── prepare.yml │ │ ├── role_install_custom_build │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── role_install_custom_version │ │ ├── converge.yml │ │ └── molecule.yml │ │ ├── role_install_default_deb │ │ ├── converge.yml │ │ ├── molecule.yml │ │ └── verify.yml │ │ ├── role_install_default_rpm │ │ ├── converge.yml │ │ ├── molecule.yml │ │ └── verify.yml │ │ └── role_install_downgrade │ │ ├── converge.yml │ │ └── molecule.yml ├── sanity │ ├── ignore-2.10.txt │ ├── ignore-2.11.txt │ ├── ignore-2.12.txt │ ├── ignore-2.13.txt │ ├── ignore-2.14.txt │ ├── ignore-2.15.txt │ ├── ignore-2.16.txt │ ├── ignore-2.9.txt │ └── validate-role-metadata.py └── unit │ ├── plugins │ ├── action │ │ └── test_bonsai_asset.py │ ├── filter │ │ ├── test_backends.py │ │ └── test_package_name.py │ ├── module_utils │ │ ├── test_arguments.py │ │ ├── test_bonsai.py │ │ ├── test_client.py │ │ ├── test_http.py │ │ ├── test_role_utils.py │ │ └── test_utils.py │ └── modules │ │ ├── common │ │ └── utils.py │ │ ├── test_ad_auth_provider.py │ │ ├── test_asset.py │ │ ├── test_asset_info.py │ │ ├── test_auth_provider_info.py │ │ ├── test_bonsai_asset.py │ │ ├── test_check.py │ │ ├── test_check_info.py │ │ ├── test_cluster.py │ │ ├── test_cluster_info.py │ │ ├── test_cluster_role.py │ │ ├── test_cluster_role_binding.py │ │ ├── test_cluster_role_binding_info.py │ │ ├── test_cluster_role_info.py │ │ ├── test_datastore.py │ │ ├── test_datastore_info.py │ │ ├── test_entity.py │ │ ├── test_entity_info.py │ │ ├── test_etcd_replicator.py │ │ ├── test_etcd_replicator_info.py │ │ ├── test_event.py │ │ ├── test_event_info.py │ │ ├── test_filter.py │ │ ├── test_filter_info.py │ │ ├── test_handler_set.py │ │ ├── test_hook.py │ │ ├── test_hook_info.py │ │ ├── test_ldap_auth_provider.py │ │ ├── test_mutator.py │ │ ├── test_mutator_info.py │ │ ├── test_namespace.py │ │ ├── test_namespace_info.py │ │ ├── test_oidc_auth_provider.py │ │ ├── test_pipe_handler.py │ │ ├── test_pipe_handler_info.py │ │ ├── test_pipeline.py │ │ ├── test_pipeline_info.py │ │ ├── test_role.py │ │ ├── test_role_binding.py │ │ ├── test_role_binding_info.py │ │ ├── test_role_info.py │ │ ├── test_secret.py │ │ ├── test_secret_info.py │ │ ├── test_secrets_provider_env.py │ │ ├── test_secrets_provider_info.py │ │ ├── test_secrets_provider_vault.py │ │ ├── test_silence.py │ │ ├── test_silence_info.py │ │ ├── test_socket_handler.py │ │ ├── test_tessen.py │ │ ├── test_user.py │ │ └── test_user_info.py │ └── requirements.txt ├── tools └── windows-versions.py └── vagrant └── windows ├── Vagrantfile ├── back.yaml ├── inventory.yaml └── play.yaml /.ansible-lint-ignore: -------------------------------------------------------------------------------- 1 | # This file contains ignores rule violations for ansible-lint 2 | roles/agent/tasks/start.yml schema[tasks] 3 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | # This configuration mirrors the configuration that is used when linting 2 | # collections on import into Ansible Galaxy. 3 | 4 | # TODO(@tadeboro): Some of our lines are almost twice the optimal reading 5 | # length of 60-80 chars. It would be great to get line lengths down to 79, but 6 | # this is not feasible at the moment since we have cca. 300 lines that are 7 | # longer. What we need is a way of preventing new long lines of getting into 8 | # the codebase, which means running flake8 with stricter rules on changed 9 | # lines only. 10 | 11 | [flake8] 12 | max-line-length = 144 13 | max-doc-length = 92 14 | 15 | exclude = 16 | # ansible-test creates all sorts of temporary stuff that we do not care 17 | # about. 18 | tests/output 19 | 20 | per-file-ignores = 21 | # Modules have their imports listed after the metadata. 22 | plugins/modules/*.py:E402 23 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | CHANGELOG.md merge=union 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Bug description** 11 | A clear and concise description of what the issue is. 12 | 13 | **How to reproduce the bug** 14 | 1. Run the command `ansible-playbook -i inv ...`. 15 | 16 | **If applicable, content of the files used in commands from the previous step** 17 | For example, `inv` file from previous sample could contain: 18 | ``` 19 | [mygroup] 20 | 10.5.126.31 21 | ``` 22 | 23 | **Expected result** 24 | A clear and concise description of what you expected to happen. 25 | 26 | **Actual result** 27 | A clear and concise description of what actually happened. Make sure you 28 | include any error messages, since they usually offer vital clues to the 29 | bug-fixing process. 30 | 31 | 32 | **Component versions** 33 | - Ansible Version [e.g. 2.9.0] 34 | - Sensu Go Collection Version [e.g. 0.7.5] 35 | - Sensu Go Backend Version [e.g. 5.14.1] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: feature 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | tests/output 2 | tests/runner 3 | docs/build 4 | docs/source/modules 5 | test_results 6 | .pytest_cache 7 | *.pyc 8 | *.swp 9 | .vagrant 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Development: [![Development status](https://circleci.com/gh/sensu/sensu-go-ansible/tree/master.svg?style=shield)](https://app.circleci.com/pipelines/github/sensu/sensu-go-ansible?branch=master) | 2 | Stable: [![Stable status](https://circleci.com/gh/sensu/sensu-go-ansible/tree/stable.svg?style=shield)](https://app.circleci.com/pipelines/github/sensu/sensu-go-ansible?branch=stable) 3 | 4 | 5 | # Sensu Go Ansible Collection 6 | 7 | Sensu Go Ansible Collection is a bundle of Ansible content that we can use to 8 | manage all aspects of Sensu Go. It contains Ansible roles for installing and 9 | configuring backends and agents. Collection also contains a wide selection of 10 | modules for runtime management of Sensu Go backend. 11 | 12 | Collection is freely available on [Ansible Galaxy][galaxy]. For Red Hat 13 | subscribers, this collection is also available on [Automation Hub][hub]. 14 | 15 | [galaxy]: https://galaxy.ansible.com/sensu/sensu_go 16 | (Sensu Go on Ansible Galaxy) 17 | [hub]: https://cloud.redhat.com/ansible/automation-hub/sensu/sensu_go 18 | (Sensu Go on Automation Hub) 19 | 20 | For user guides and references, please visit [the documentation site][docs]. 21 | And if you would like to help us out, check our [hacking docs][hacking]. 22 | 23 | [docs]: https://sensu.github.io/sensu-go-ansible/ 24 | (Sensu Go Ansible Collection documentation) 25 | [hacking]: https://sensu.github.io/sensu-go-ansible/hacking.html 26 | (Developer guides) 27 | -------------------------------------------------------------------------------- /collection.requirements: -------------------------------------------------------------------------------- 1 | bcrypt 2 | -------------------------------------------------------------------------------- /docker/alma-8.docker: -------------------------------------------------------------------------------- 1 | FROM almalinux:8 2 | RUN dnf makecache \ 3 | && dnf install -y \ 4 | /usr/bin/python3 /usr/bin/python3-config /usr/bin/dnf-3 \ 5 | sudo bash iproute \ 6 | && dnf clean all 7 | -------------------------------------------------------------------------------- /docker/amazon-1.docker: -------------------------------------------------------------------------------- 1 | FROM amazonlinux:1 2 | ENV container docker 3 | RUN \ 4 | yum makecache fast; \ 5 | yum install -y \ 6 | /usr/bin/python /usr/bin/python2-config sudo \ 7 | yum-plugin-ovl bash iproute shadow-utils; \ 8 | sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf; \ 9 | yum clean all 10 | -------------------------------------------------------------------------------- /docker/amazon-2.docker: -------------------------------------------------------------------------------- 1 | FROM amazonlinux:2 2 | ENV container docker 3 | RUN \ 4 | yum makecache fast; \ 5 | yum install -y \ 6 | /usr/bin/python /usr/bin/python2-config sudo \ 7 | yum-plugin-ovl bash iproute shadow-utils; \ 8 | sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf; \ 9 | yum clean all 10 | -------------------------------------------------------------------------------- /docker/build-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | 3 | set -o pipefail 4 | 5 | for f in *.docker 6 | do 7 | ./build.sh "$f" 8 | done 9 | -------------------------------------------------------------------------------- /docker/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | 3 | set -o pipefail 4 | 5 | readonly filename="$1"; shift 6 | 7 | readonly base=${filename%.docker} 8 | readonly name=${base%-*} 9 | readonly version=${base##*-} 10 | readonly tag="quay.io/xlab-steampunk/sensu-go-tests-$name:$version" 11 | 12 | docker build --pull -f "$filename" -t "$tag" . 13 | docker push "$tag" 14 | -------------------------------------------------------------------------------- /docker/centos-6.docker: -------------------------------------------------------------------------------- 1 | FROM centos:6 2 | RUN yum makecache fast \ 3 | && yum install -y \ 4 | /usr/bin/python /usr/bin/python2-config sudo \ 5 | yum-plugin-ovl bash iproute \ 6 | && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf \ 7 | && yum clean all 8 | -------------------------------------------------------------------------------- /docker/centos-7.docker: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | ENV container docker 3 | RUN ( \ 4 | cd /lib/systemd/system/sysinit.target.wants/; \ 5 | for i in *; do \ 6 | [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; \ 7 | done \ 8 | ); \ 9 | rm -f /lib/systemd/system/multi-user.target.wants/*;\ 10 | rm -f /etc/systemd/system/*.wants/*;\ 11 | rm -f /lib/systemd/system/local-fs.target.wants/*; \ 12 | rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ 13 | rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ 14 | rm -f /lib/systemd/system/basic.target.wants/*;\ 15 | rm -f /lib/systemd/system/anaconda.target.wants/*; \ 16 | yum makecache fast; \ 17 | yum install -y \ 18 | /usr/bin/python /usr/bin/python2-config sudo \ 19 | yum-plugin-ovl bash iproute; \ 20 | sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf; \ 21 | yum -y update systemd; \ 22 | yum clean all; \ 23 | chmod 777 /root; 24 | 25 | VOLUME [ "/sys/fs/cgroup" ] 26 | CMD [ "/usr/sbin/init" ] 27 | -------------------------------------------------------------------------------- /docker/centos-8.docker: -------------------------------------------------------------------------------- 1 | FROM centos:8 2 | RUN dnf makecache \ 3 | && dnf install -y \ 4 | /usr/bin/python3 /usr/bin/python3-config /usr/bin/dnf-3 \ 5 | sudo bash iproute \ 6 | && dnf clean all 7 | -------------------------------------------------------------------------------- /docker/debian-10.docker: -------------------------------------------------------------------------------- 1 | FROM debian:10 2 | RUN apt-get update \ 3 | && apt-get install -y \ 4 | python sudo bash ca-certificates iproute2 python-apt aptitude \ 5 | && rm -rf /var/lib/apt/lists/* \ 6 | && rm -rf /usr/share/doc \ 7 | && rm -rf /usr/share/man \ 8 | && apt-get clean 9 | -------------------------------------------------------------------------------- /docker/debian-9.docker: -------------------------------------------------------------------------------- 1 | FROM debian:9 2 | RUN apt-get update \ 3 | && apt-get install -y \ 4 | python sudo bash ca-certificates iproute2 python-apt aptitude \ 5 | && apt-get clean 6 | -------------------------------------------------------------------------------- /docker/oracle-8.docker: -------------------------------------------------------------------------------- 1 | FROM oraclelinux:8 2 | RUN dnf makecache \ 3 | && dnf install -y \ 4 | /usr/bin/python3 /usr/bin/python3-config /usr/bin/dnf-3 \ 5 | sudo bash iproute \ 6 | && dnf clean all 7 | -------------------------------------------------------------------------------- /docker/redhat-7.docker: -------------------------------------------------------------------------------- 1 | FROM registry.access.redhat.com/ubi7/ubi-init:latest 2 | RUN yum makecache fast \ 3 | && yum install -y \ 4 | /usr/bin/python /usr/bin/python2-config sudo \ 5 | yum-plugin-ovl bash iproute \ 6 | && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf \ 7 | && yum clean all 8 | -------------------------------------------------------------------------------- /docker/rocky-8.docker: -------------------------------------------------------------------------------- 1 | FROM rockylinux:8 2 | RUN dnf makecache \ 3 | && dnf install -y \ 4 | /usr/bin/python3 /usr/bin/python3-config /usr/bin/dnf-3 \ 5 | sudo bash iproute \ 6 | && dnf clean all 7 | -------------------------------------------------------------------------------- /docker/sensu-5.14.2.docker: -------------------------------------------------------------------------------- 1 | FROM sensu/sensu:5.14.2 2 | RUN apk update \ 3 | && apk add --no-cache python sudo bash ca-certificates 4 | CMD [ \ 5 | "sensu-backend", "start", \ 6 | "--state-dir", "/var/lib/sensu/sensu-backend", \ 7 | "--log-level", "debug" \ 8 | ] 9 | -------------------------------------------------------------------------------- /docker/sensu-5.21.3.docker: -------------------------------------------------------------------------------- 1 | FROM sensu/sensu:5.21.3 2 | RUN apk update \ 3 | && apk add --no-cache python sudo bash ca-certificates \ 4 | py-bcrypt py-six py-cffi 5 | CMD [ \ 6 | "sensu-backend", "start", \ 7 | "--state-dir", "/var/lib/sensu/sensu-backend", \ 8 | "--log-level", "debug" \ 9 | ] 10 | -------------------------------------------------------------------------------- /docker/sensu-6.10.0.docker: -------------------------------------------------------------------------------- 1 | FROM sensu/sensu:6.10.0 2 | RUN apk update \ 3 | && apk add --no-cache python3 py3-bcrypt py3-six py3-cffi bash 4 | CMD [ \ 5 | "sensu-backend", "start", \ 6 | "--state-dir", "/var/lib/sensu/sensu-backend", \ 7 | "--log-level", "debug" \ 8 | ] -------------------------------------------------------------------------------- /docker/sensu-6.2.5.docker: -------------------------------------------------------------------------------- 1 | FROM sensu/sensu:6.2.5 2 | RUN apk update \ 3 | && apk add --no-cache python3 py3-bcrypt py3-six py3-cffi bash 4 | CMD [ \ 5 | "sensu-backend", "start", \ 6 | "--state-dir", "/var/lib/sensu/sensu-backend", \ 7 | "--log-level", "debug" \ 8 | ] 9 | -------------------------------------------------------------------------------- /docker/sensu-6.3.0.docker: -------------------------------------------------------------------------------- 1 | FROM sensu/sensu:6.3.0 2 | RUN apk update \ 3 | && apk add --no-cache python3 py3-bcrypt py3-six py3-cffi bash 4 | CMD [ \ 5 | "sensu-backend", "start", \ 6 | "--state-dir", "/var/lib/sensu/sensu-backend", \ 7 | "--log-level", "debug" \ 8 | ] 9 | -------------------------------------------------------------------------------- /docker/sensu-6.4.3.docker: -------------------------------------------------------------------------------- 1 | FROM sensu/sensu:6.4.3 2 | RUN apk update \ 3 | && apk add --no-cache python3 py3-bcrypt py3-six py3-cffi bash 4 | CMD [ \ 5 | "sensu-backend", "start", \ 6 | "--state-dir", "/var/lib/sensu/sensu-backend", \ 7 | "--log-level", "debug" \ 8 | ] 9 | -------------------------------------------------------------------------------- /docker/sensu-6.5.5.docker: -------------------------------------------------------------------------------- 1 | FROM sensu/sensu:6.5.5 2 | RUN apk update \ 3 | && apk add --no-cache python3 py3-bcrypt py3-six py3-cffi bash 4 | CMD [ \ 5 | "sensu-backend", "start", \ 6 | "--state-dir", "/var/lib/sensu/sensu-backend", \ 7 | "--log-level", "debug" \ 8 | ] 9 | -------------------------------------------------------------------------------- /docker/sensu-6.6.2.docker: -------------------------------------------------------------------------------- 1 | FROM sensu/sensu:6.6.2 2 | RUN apk update \ 3 | && apk add --no-cache python3 py3-bcrypt py3-six py3-cffi bash 4 | CMD [ \ 5 | "sensu-backend", "start", \ 6 | "--state-dir", "/var/lib/sensu/sensu-backend", \ 7 | "--log-level", "debug" \ 8 | ] 9 | -------------------------------------------------------------------------------- /docker/sensu-6.7.5.docker: -------------------------------------------------------------------------------- 1 | FROM sensu/sensu:6.7.5 2 | RUN apk update \ 3 | && apk add --no-cache python3 py3-bcrypt py3-six py3-cffi bash 4 | CMD [ \ 5 | "sensu-backend", "start", \ 6 | "--state-dir", "/var/lib/sensu/sensu-backend", \ 7 | "--log-level", "debug" \ 8 | ] 9 | -------------------------------------------------------------------------------- /docker/sensu-6.8.2.docker: -------------------------------------------------------------------------------- 1 | FROM sensu/sensu:6.8.2 2 | RUN apk update \ 3 | && apk add --no-cache python3 py3-bcrypt py3-six py3-cffi bash 4 | CMD [ \ 5 | "sensu-backend", "start", \ 6 | "--state-dir", "/var/lib/sensu/sensu-backend", \ 7 | "--log-level", "debug" \ 8 | ] 9 | -------------------------------------------------------------------------------- /docker/sensu-6.9.0.docker: -------------------------------------------------------------------------------- 1 | FROM sensu/sensu:6.9.0 2 | RUN apk update \ 3 | && apk add --no-cache python3 py3-bcrypt py3-six py3-cffi bash 4 | CMD [ \ 5 | "sensu-backend", "start", \ 6 | "--state-dir", "/var/lib/sensu/sensu-backend", \ 7 | "--log-level", "debug" \ 8 | ] 9 | -------------------------------------------------------------------------------- /docker/ubuntu-14.04.docker: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | RUN rm \ 3 | /etc/apt/apt.conf.d/20apt-esm-hook.conf \ 4 | /etc/apt/sources.list.d/ubuntu-esm-infra-trusty.list \ 5 | && apt-get update \ 6 | && apt-get install -y \ 7 | python sudo bash ca-certificates iproute2 python-apt aptitude \ 8 | && apt-get clean 9 | -------------------------------------------------------------------------------- /docker/ubuntu-16.04.docker: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | RUN apt-get update \ 3 | && apt-get install -y \ 4 | python sudo bash ca-certificates iproute2 python-apt aptitude \ 5 | && apt-get clean 6 | -------------------------------------------------------------------------------- /docker/ubuntu-18.04.docker: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | RUN apt-get update \ 3 | && apt-get install -y \ 4 | python sudo bash ca-certificates iproute2 python-apt aptitude \ 5 | && apt-get clean 6 | -------------------------------------------------------------------------------- /docker/ubuntu-20.04.docker: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | RUN apt-get update \ 3 | && apt-get install -y \ 4 | python sudo bash ca-certificates iproute2 python-apt aptitude \ 5 | && apt-get clean 6 | -------------------------------------------------------------------------------- /docker/ubuntu-22.04.docker: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | RUN apt-get update \ 3 | && apt-get install -y \ 4 | python3 sudo bash ca-certificates iproute2 python3-apt aptitude \ 5 | && apt-get clean 6 | -------------------------------------------------------------------------------- /docs.requirements: -------------------------------------------------------------------------------- 1 | Sphinx 2 | sphinx-rtd-theme 3 | ansible-doc-extractor 4 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/Makefile.custom: -------------------------------------------------------------------------------- 1 | modules := $(wildcard ../plugins/modules/*.py) 2 | module_docs := $(modules:../plugins/modules/%.py=source/modules/%.rst) 3 | doc_fragments := $(wildcard ../plugins/doc_fragments/*.py) 4 | template := templates/module.rst.j2 5 | 6 | export ANSIBLE_COLLECTIONS_PATHS ?= $(realpath $(CURDIR)/../../../..) 7 | 8 | 9 | .PHONY: all 10 | docs: $(module_docs) 11 | $(MAKE) html 12 | 13 | .PHONY: clean 14 | clean: 15 | rm -rf build source/modules 16 | 17 | source/modules/%.rst: ../plugins/modules/%.py $(doc_fragments) $(template) 18 | mkdir -p source/modules 19 | ansible-doc-extractor --template $(template) source/modules $< 20 | -------------------------------------------------------------------------------- /docs/examples/installation/ansible.cfg: -------------------------------------------------------------------------------- 1 | [galaxy] 2 | server_list = automation_hub, galaxy 3 | 4 | [galaxy_server.automation_hub] 5 | url=https://cloud.redhat.com/api/automation-hub/ 6 | auth_url=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token 7 | token=AABBccddeeff112233gghh... 8 | 9 | [galaxy_server.galaxy] 10 | url=https://galaxy.ansible.com/ 11 | -------------------------------------------------------------------------------- /docs/examples/quickstart/inventory.yaml: -------------------------------------------------------------------------------- 1 | all: 2 | children: 3 | backends: 4 | hosts: 5 | 192.168.50.4: 6 | 7 | agents: 8 | hosts: 9 | 192.168.50.5: 10 | -------------------------------------------------------------------------------- /docs/examples/quickstart/playbook-5.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install, configure and run Sensu backend 3 | hosts: backends 4 | become: true 5 | 6 | tasks: 7 | - name: Install backend 8 | include_role: 9 | name: sensu.sensu_go.backend 10 | vars: 11 | version: 5.21.2 12 | 13 | - name: Install, configure and run Sensu agents 14 | hosts: agents 15 | become: true 16 | 17 | tasks: 18 | - name: Install agent 19 | include_role: 20 | name: sensu.sensu_go.agent 21 | vars: 22 | version: 5.21.2 23 | agent_config: 24 | deregister: true 25 | keepalive-interval: 5 26 | keepalive-timeout: 10 27 | subscriptions: 28 | - linux 29 | 30 | - name: Configure your first monitor 31 | hosts: localhost 32 | tasks: 33 | - name: Create sensu asset 34 | sensu.sensu_go.bonsai_asset: 35 | auth: &auth 36 | url: http://{{ groups['backends'][0] }}:8080 37 | name: sensu/monitoring-plugins 38 | version: 2.2.0-1 39 | 40 | - name: Create sensu ntp check 41 | sensu.sensu_go.check: 42 | auth: *auth 43 | name: ntp 44 | runtime_assets: sensu/monitoring-plugins 45 | command: check_ntp_time -H time.nist.gov --warn 0.5 --critical 1.0 46 | output_metric_format: nagios_perfdata 47 | publish: true 48 | interval: 30 49 | timeout: 10 50 | subscriptions: 51 | - linux 52 | -------------------------------------------------------------------------------- /docs/examples/quickstart/playbook-6.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install, configure and run Sensu backend 3 | hosts: backends 4 | become: true 5 | 6 | tasks: 7 | - name: Install backend 8 | include_role: 9 | name: sensu.sensu_go.backend 10 | vars: 11 | version: 6.0.0 12 | 13 | - name: Install, configure and run Sensu agents 14 | hosts: agents 15 | become: true 16 | 17 | tasks: 18 | - name: Install agent 19 | include_role: 20 | name: sensu.sensu_go.agent 21 | vars: 22 | version: 6.0.0 23 | agent_config: 24 | name: my-agent 25 | keepalive-interval: 5 26 | keepalive-timeout: 10 27 | 28 | - name: Configure your first monitor 29 | hosts: localhost 30 | tasks: 31 | - name: Add subscriptions to agent entity 32 | sensu.sensu_go.entity: 33 | auth: &auth 34 | url: http://{{ groups['backends'][0] }}:8080 35 | name: my-agent 36 | entity_class: agent 37 | deregister: true 38 | subscriptions: 39 | - linux 40 | 41 | - name: Create sensu asset 42 | sensu.sensu_go.bonsai_asset: 43 | auth: *auth 44 | name: sensu/monitoring-plugins 45 | version: 2.2.0-1 46 | 47 | - name: Create sensu ntp check 48 | sensu.sensu_go.check: 49 | auth: *auth 50 | name: ntp 51 | runtime_assets: sensu/monitoring-plugins 52 | command: check_ntp_time -H time.nist.gov --warn 0.5 --critical 1.0 53 | output_metric_format: nagios_perfdata 54 | publish: true 55 | interval: 30 56 | timeout: 10 57 | subscriptions: 58 | - linux 59 | -------------------------------------------------------------------------------- /docs/examples/roles/agent.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install, configure and run Sensu agent 3 | hosts: agents 4 | roles: 5 | - sensu.sensu_go.agent 6 | vars: 7 | agent_config: 8 | backend-url: ["ws://upstream-backend:4321"] 9 | -------------------------------------------------------------------------------- /docs/examples/roles/backend.yaml: -------------------------------------------------------------------------------- 1 | - name: Install, configure and run Sensu backend 2 | hosts: backends 3 | roles: 4 | - sensu.sensu_go.backend 5 | vars: 6 | backend_config: 7 | log-level: debug 8 | -------------------------------------------------------------------------------- /docs/examples/roles/install.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install latest sensu-backend binary from stable channel 3 | hosts: backends 4 | roles: 5 | - sensu.sensu_go.install 6 | vars: 7 | components: [sensu-go-backend] 8 | 9 | - name: Install latest sensu-agent binary from testing channel 10 | hosts: agents 11 | roles: 12 | - sensu.sensu_go.install 13 | vars: 14 | components: [sensu-go-agent] 15 | channel: testing 16 | 17 | - name: Install a specific version of sensuctl binary from stable channel 18 | hosts: localhost 19 | roles: 20 | - sensu.sensu_go.install 21 | vars: 22 | components: [sensu-go-cli] 23 | version: 5.14.2 24 | -------------------------------------------------------------------------------- /docs/source/conf.py: -------------------------------------------------------------------------------- 1 | project = "Sensu Go Ansible Collection" 2 | copyright = "2019, XLAB Steampunk" 3 | author = "XLAB Steampunk" 4 | 5 | extensions = [ 6 | "sphinx_rtd_theme", 7 | ] 8 | exclude_patterns = [] 9 | 10 | html_theme = "sphinx_rtd_theme" 11 | html_context = { 12 | "display_github": True, 13 | "github_user": "sensu", 14 | "github_repo": "sensu-go-ansible", 15 | "github_version": "master", 16 | "conf_py_path": "/docs/source/", 17 | } 18 | -------------------------------------------------------------------------------- /docs/source/hacking.rst: -------------------------------------------------------------------------------- 1 | Developing Sensu Go Ansible Collection 2 | ====================================== 3 | 4 | So, you have decided to help us out. Great! Let us set up a development 5 | environment together, and then we can start hacking ;) 6 | 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | :caption: Content 11 | 12 | hacking/setup 13 | hacking/testing 14 | hacking/docker-images 15 | hacking/documentation 16 | hacking/windows 17 | hacking/releases 18 | -------------------------------------------------------------------------------- /docs/source/hacking/docker-images.rst: -------------------------------------------------------------------------------- 1 | Preparing docker images for integration tests 2 | ============================================= 3 | 4 | Our test suite relies heavily on custom docker images for testing. The main 5 | reason that we use custom images is test speed: having prepared docker images 6 | vs. building them on each test execution saves a ton of time. 7 | 8 | Adding a new image is relatively straightforward process. We can just copy one 9 | of the preexisting definitions from the *docker* directory and update it. All 10 | docker files should have a name in the format of ``-.docker``. 11 | 12 | To build and publish our image, we can run the *docker/build.sh* script:: 13 | 14 | $ cd docker 15 | $ ./build.sh sensu-6.10.0.docker 16 | 17 | Note that the command will add a *sensu-go-tests-* prefix to all images. In 18 | the previous example, the build script will build the 19 | *quay.io/xlab-steampunk/sensu-go-tests-sensu:6.10.0* image. 20 | -------------------------------------------------------------------------------- /docs/source/hacking/releases.rst: -------------------------------------------------------------------------------- 1 | Releasing the Sensu Go Ansible Collection 2 | ========================================= 3 | 4 | The Sensu Go Ansible collection is primarily available from `Ansible Galaxy`_ 5 | and `Automation Hub`_. Which means that we need to get our content up there 6 | somehow. But before we can start uploading things, we need to do some chores 7 | first. 8 | 9 | .. _Ansible Galaxy: 10 | https://galaxy.ansible.com/sensu/sensu_go 11 | 12 | .. _Automation Hub: 13 | https://cloud.redhat.com/ansible/automation-hub/sensu/sensu_go 14 | 15 | 16 | First, we need to tag the commit and move the ``stable`` branch forward:: 17 | 18 | $ VERSION=$(grep version: galaxy.yml | cut -d" " -f2) 19 | $ git tag -am "Version $VERSION" v$VERSION 20 | $ git branch -f stable v$VERSION 21 | 22 | Now, we need to package the collection. Because the ``ansible-galaxy 23 | collection build`` command will package anything that it can find next to the 24 | ``galaxy.yml`` file, we need to execute it in a clean environment. This is why 25 | we will temporarily check out the *stable* branch into the *release* 26 | subdirectory, build the collection package, and then delete the checkout. This 27 | translates into the following sequence of commands:: 28 | 29 | $ git worktree add release stable 30 | $ cd release 31 | $ ansible-galaxy collection build 32 | $ mv sensu-sensu_go-$VERSION.tar.gz .. 33 | $ cd .. 34 | $ git worktree remove release 35 | 36 | Now we can upload the package to Ansible Galaxy:: 37 | 38 | $ API_KEY=api-key-from-https://galaxy.ansible.com/me/preferences 39 | $ ansible-galaxy collection publish \ 40 | --api-key "$API_KEY" \ 41 | sensu-sensu_go-$VERSION.tar.gz 42 | 43 | Last thing we need to do is push the ``stable`` branch and created tag to the 44 | GitHub and attach the package to the GitHub release:: 45 | 46 | $ git push origin stable v$VERSION 47 | 48 | We need to attach the asset manually at the moment. Fully automated solution 49 | is in the works. 50 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | Sensu Go Ansible Collection 2 | =========================== 3 | 4 | Sensu Go Ansible Collection is a bundle of Ansible content that we can use to 5 | manage all aspects of Sensu Go. It contains Ansible roles for installing and 6 | configuring backends and agents. Collection also contains a wide selection of 7 | modules for runtime management of Sensu Go backend. 8 | 9 | Collection is freely available on `Ansible Galaxy`_. For Red Hat subscribers, 10 | this collection is also available on `Automation Hub`_. 11 | 12 | .. _Ansible Galaxy: 13 | https://galaxy.ansible.com/sensu/sensu_go 14 | .. _Automation Hub: 15 | https://cloud.redhat.com/ansible/automation-hub/sensu/sensu_go 16 | 17 | 18 | .. toctree:: 19 | :maxdepth: 2 20 | :caption: Using Sensu Go Ansible Collection 21 | 22 | quickstart-sensu-go-6 23 | quickstart-sensu-go-5 24 | installation 25 | 26 | 27 | .. toctree:: 28 | :maxdepth: 2 29 | :caption: Guides 30 | 31 | versioning_sensu_go_installation 32 | sensu_go_5_6_migration 33 | 34 | 35 | .. toctree:: 36 | :maxdepth: 1 37 | :caption: References 38 | 39 | roles 40 | modules 41 | 42 | .. toctree:: 43 | :maxdepth: 1 44 | :caption: Hacker's guides 45 | 46 | hacking 47 | 48 | .. toctree:: 49 | :maxdepth: 1 50 | :caption: Appendices 51 | 52 | release_policy 53 | release_notes 54 | -------------------------------------------------------------------------------- /docs/source/quickstart-sensu-go-5.rst: -------------------------------------------------------------------------------- 1 | Quickstart for Sensu Go 5 2 | ========================= 3 | 4 | Before we can do anything, we need to install Sensu Go Ansible Collection. 5 | Luckily, we are just one short command away from that goal:: 6 | 7 | $ ansible-galaxy collection install sensu.sensu_go 8 | 9 | Now we can set up a simple Sensu Go sandbox using the following 10 | :download:`playbook <../examples/quickstart/playbook-5.yaml>`: 11 | 12 | .. literalinclude:: ../examples/quickstart/playbook-5.yaml 13 | :language: yaml 14 | 15 | When we run it, Ansible will install and configure backend and agents on 16 | selected hosts, and then configure a ntp check that agents will execute twice 17 | a minute. Note that we do not need to inform agents explicitly where the 18 | backend is because the :doc:`agent role ` can obtain the 19 | backend's address from the inventory. 20 | 21 | Now, before we can run this playbook, we need to prepare an inventory file. 22 | The inventory should contain two groups of hosts: *backends* and *agents*. A 23 | :download:`minimal inventory <../examples/quickstart/inventory.yaml>` with 24 | only two hosts will look somewhat like this: 25 | 26 | .. literalinclude:: ../examples/quickstart/inventory.yaml 27 | :language: yaml 28 | 29 | Replace the IP addresses with your own and make sure you can ssh into those 30 | hosts. If you need help with building your inventory file, consult `official 31 | documentation on inventory`_. 32 | 33 | .. _official documentation on inventory: 34 | https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html 35 | 36 | All that we need to do now is to run the playbook:: 37 | 38 | $ ansible-playbook -i inventory.yaml playbook-5.yaml 39 | 40 | And in a few minutes, things should be ready to go. And if we now visit 41 | http://192.168.50.4:3000 (replace that IP address with the address of your 42 | backend), we can log in and start exploring. 43 | -------------------------------------------------------------------------------- /docs/source/quickstart-sensu-go-6.rst: -------------------------------------------------------------------------------- 1 | Quickstart for Sensu Go 6 2 | ========================= 3 | 4 | Before we can do anything, we need to install Sensu Go Ansible Collection. 5 | Luckily, we are just one short command away from that goal:: 6 | 7 | $ ansible-galaxy collection install sensu.sensu_go 8 | 9 | Now we can set up a simple Sensu Go sandbox using the following 10 | :download:`playbook <../examples/quickstart/playbook-6.yaml>`: 11 | 12 | .. literalinclude:: ../examples/quickstart/playbook-6.yaml 13 | :language: yaml 14 | 15 | When we run it, Ansible will install and configure backend and agents on 16 | selected hosts, and then configure a ntp check that agents will execute twice 17 | a minute. Note that we do not need to inform agents explicitly where the 18 | backend is because the :doc:`agent role ` can obtain the 19 | backend's address from the inventory. 20 | 21 | Now, before we can run this playbook, we need to prepare an inventory file. 22 | The inventory should contain two groups of hosts: *backends* and *agents*. A 23 | :download:`minimal inventory <../examples/quickstart/inventory.yaml>` with 24 | only two hosts will look somewhat like this: 25 | 26 | .. literalinclude:: ../examples/quickstart/inventory.yaml 27 | :language: yaml 28 | 29 | Replace the IP addresses with your own and make sure you can ssh into those 30 | hosts. If you need help with building your inventory file, consult `official 31 | documentation on inventory`_. 32 | 33 | .. _official documentation on inventory: 34 | https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html 35 | 36 | All that we need to do now is to run the playbook:: 37 | 38 | $ ansible-playbook -i inventory.yaml playbook-6.yaml 39 | 40 | And in a few minutes, things should be ready to go. And if we now visit 41 | http://192.168.50.4:3000 (replace that IP address with the address of your 42 | backend), we can log in and start exploring. 43 | -------------------------------------------------------------------------------- /docs/source/release_policy.rst: -------------------------------------------------------------------------------- 1 | Release policy 2 | ============== 3 | 4 | Our release policy could be summarized as: 5 | 6 | 1. We only support latest stable release. 7 | 2. We create new bugfix and feature releases as things progress and not on a 8 | fixed schedule. 9 | 3. We support deprecated content for at least a year and a half since its 10 | deprecation. 11 | 4. We have no plans on releasing version 2.0.0 anytime soon and are fully 12 | commited on making current version of collection work on all supported 13 | Sensu Go versions. 14 | 15 | 16 | Supported releases 17 | ------------------ 18 | 19 | As already stated, we only support latest stable version of Sensu Go Ansible 20 | Collection. Currently, this means that only latest 1.x.y version is supported. 21 | 22 | Once we next major version of collection, we will continue to backport 23 | security fixes to previous major version 1 for at least half a year. No new 24 | features will be backported. 25 | 26 | 27 | Release schedule 28 | ---------------- 29 | 30 | To get new features and bugfixes to our users as soon as possible, we have no 31 | fixed release schedule. Instead, we create a new release after each 32 | significant change (bugfix or added feature). We may delay release for a day 33 | or two if we have a few thing lined up to reduce the administrative load. 34 | 35 | 36 | Compatibility 37 | ------------- 38 | 39 | Sensu Go Ansible Collection follows `semantic versioning`_. In short, we 40 | guarantee backward compatibility between releases with the same major version 41 | number. In practice, this means that if we have a playbook that works with 42 | some version of Sensu Go Ansible Collection, it will continue to work with 43 | newer versions up until major version changes. 44 | 45 | .. _semantic versioning: https://semver.org/ 46 | 47 | We do not guarantee forward compatibility (we are adding new modules in 48 | releases that increment minor version number). Downgrading between patch 49 | versions should be safe, but we would advice against it because patch releases 50 | can potentially contain important security fixes. 51 | -------------------------------------------------------------------------------- /docs/source/roles.rst: -------------------------------------------------------------------------------- 1 | Roles 2 | ===== 3 | 4 | Sensu Go Ansible Collection contains three roles that allow us install and 5 | configure Sensu Go backend and agents. 6 | 7 | .. toctree:: 8 | :glob: 9 | :maxdepth: 1 10 | 11 | roles/* 12 | -------------------------------------------------------------------------------- /docs/source/roles/agent.rst: -------------------------------------------------------------------------------- 1 | Sensu Go agent role 2 | =================== 3 | 4 | This role installs, configures and starts the ``sensu-agent`` service. 5 | 6 | 7 | Example playbook 8 | ---------------- 9 | 10 | The most basic 11 | :download:`agent playbook <../../examples/roles/agent.yaml>` looks like this: 12 | 13 | .. literalinclude:: ../../examples/roles/agent.yaml 14 | :language: yaml 15 | 16 | This playbook will install the latest stable version of the Sensu Go agent 17 | and configure it. We can customize the agent's configuration by adding more 18 | options to the *agent_config* variable. 19 | 20 | 21 | Agent configuration options 22 | --------------------------- 23 | 24 | The *agent_config* variable can contain any option that is valid for the Sensu 25 | Go agent version we are installing. All valid options are listed in the 26 | `official Sensu documentation`_. 27 | 28 | .. _official Sensu documentation: 29 | https://docs.sensu.io/sensu-go/latest/reference/agent/#configuration 30 | 31 | .. note:: 32 | 33 | Role copies the key-value pairs from the *agent_config* variable verbatim 34 | to the configuration file. This means that we must copy the key names 35 | **exactly** as they appear in the configuration reference. In a way, the 36 | *agent_config* variable should contain a properly indented copy of the 37 | ``/etc/sensu/agent.yml`` file. 38 | 39 | 40 | Tested Platforms (CI/CD) 41 | ------------------------ 42 | 43 | +-------+--------------+-----------------------------------+ 44 | | OS | distribution | versions | 45 | +=======+==============+===================================+ 46 | | Linux | CentOS | 7 | 47 | | +--------------+-----------------------------------+ 48 | | | RedHat | 7, 8 | 49 | | +--------------+-----------------------------------+ 50 | | | Debian | 9, 10 | 51 | | +--------------+-----------------------------------+ 52 | | | Ubuntu | 14.04, 16.04, 18.04 | 53 | +-------+--------------+-----------------------------------+ 54 | -------------------------------------------------------------------------------- /galaxy.yml: -------------------------------------------------------------------------------- 1 | namespace: sensu 2 | name: sensu_go 3 | version: 1.14.0 4 | 5 | authors: 6 | - Paul Arthur (@flowerysong) 7 | - XLAB Steampunk 8 | 9 | tags: 10 | - sensu 11 | - sensugo 12 | - monitoring 13 | 14 | readme: README.md 15 | license_file: COPYING 16 | description: Roles and modules for installing and using Sensu Go 17 | 18 | repository: https://github.com/sensu/sensu-go-ansible 19 | issues: https://github.com/sensu/sensu-go-ansible/issues 20 | documentation: https://sensu.github.io/sensu-go-ansible/ 21 | homepage: https://sensu.github.io/sensu-go-ansible/ 22 | -------------------------------------------------------------------------------- /integration.requirements: -------------------------------------------------------------------------------- 1 | molecule ~= 6.0.1; python_version >= "3.10" 2 | molecule ~= 5.0.1; python_version < "3.10" 3 | molecule-docker ~= 2.1.0 4 | pytest 5 | pytest-molecule ~= 2.0.0 -------------------------------------------------------------------------------- /meta/execution-environment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 1 3 | dependencies: 4 | python: collection.requirements 5 | -------------------------------------------------------------------------------- /meta/runtime.yml: -------------------------------------------------------------------------------- 1 | --- 2 | requires_ansible: ">=2.9.0" 3 | -------------------------------------------------------------------------------- /molecule.yml: -------------------------------------------------------------------------------- 1 | collections: 2 | - name: ansible.posix -------------------------------------------------------------------------------- /plugins/doc_fragments/annotations.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright: (c) 2019, XLAB Steampunk 3 | # 4 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import (absolute_import, division, print_function) 7 | __metaclass__ = type 8 | 9 | 10 | class ModuleDocFragment(object): 11 | DOCUMENTATION = """ 12 | options: 13 | annotations: 14 | description: 15 | - Custom metadata fields with fewer restrictions, as key/value pairs. 16 | - These are preserved by Sensu but not accessible as tokens or 17 | identifiers, and are mainly intended for use with external tools. 18 | type: dict 19 | default: {} 20 | """ 21 | -------------------------------------------------------------------------------- /plugins/doc_fragments/info.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright: (c) 2019, Paul Arthur 3 | # 4 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import (absolute_import, division, print_function) 7 | __metaclass__ = type 8 | 9 | 10 | class ModuleDocFragment(object): 11 | DOCUMENTATION = """ 12 | options: 13 | name: 14 | description: 15 | - Retrieve information about this specific object instead of listing all objects. 16 | type: str 17 | """ 18 | -------------------------------------------------------------------------------- /plugins/doc_fragments/labels.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright: (c) 2019, XLAB Steampunk 3 | # 4 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import (absolute_import, division, print_function) 7 | __metaclass__ = type 8 | 9 | 10 | class ModuleDocFragment(object): 11 | DOCUMENTATION = """ 12 | options: 13 | labels: 14 | description: 15 | - Custom metadata fields that can be accessed within Sensu, as key/value 16 | pairs. 17 | type: dict 18 | default: {} 19 | """ 20 | -------------------------------------------------------------------------------- /plugins/doc_fragments/name.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright: (c) 2019, XLAB Steampunk 3 | # 4 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import (absolute_import, division, print_function) 7 | __metaclass__ = type 8 | 9 | 10 | class ModuleDocFragment(object): 11 | DOCUMENTATION = """ 12 | options: 13 | name: 14 | description: 15 | - The Sensu resource's name. This name (in combination with the 16 | namespace where applicable) uniquely identifies the resource that 17 | Ansible operates on. 18 | - If the resource with selected name already exists, Ansible module will 19 | update it to match the specification in the task. 20 | - Consult the I(name) metadata attribute specification in the upstream 21 | docs on U(https://docs.sensu.io/sensu-go/latest/reference/) for 22 | more details about valid names and other restrictions. 23 | type: str 24 | required: yes 25 | """ 26 | -------------------------------------------------------------------------------- /plugins/doc_fragments/namespace.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright: (c) 2019, XLAB Steampunk 3 | # 4 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import (absolute_import, division, print_function) 7 | __metaclass__ = type 8 | 9 | 10 | class ModuleDocFragment(object): 11 | DOCUMENTATION = """ 12 | options: 13 | namespace: 14 | description: 15 | - RBAC namespace to operate in. If this is not set the value of the 16 | SENSU_NAMESPACE environment variable will be used. 17 | type: str 18 | default: default 19 | """ 20 | -------------------------------------------------------------------------------- /plugins/doc_fragments/requirements.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright: (c) 2021, XLAB Steampunk 3 | # 4 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import (absolute_import, division, print_function) 7 | __metaclass__ = type 8 | 9 | 10 | class ModuleDocFragment(object): 11 | # We have an empty options key because ansible fails without it. 12 | DOCUMENTATION = """ 13 | options: {} 14 | requirements: 15 | - python >= 2.7 16 | """ 17 | -------------------------------------------------------------------------------- /plugins/doc_fragments/secrets.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright: (c) 2020, XLAB Steampunk 3 | # 4 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import (absolute_import, division, print_function) 7 | __metaclass__ = type 8 | 9 | 10 | class ModuleDocFragment(object): 11 | DOCUMENTATION = """ 12 | options: 13 | secrets: 14 | description: 15 | - List of secrets that are available to the command. 16 | type: list 17 | elements: dict 18 | version_added: 1.6.0 19 | suboptions: 20 | name: 21 | description: 22 | - Variable name that will contain the sensitive data. 23 | type: str 24 | required: true 25 | version_added: 1.6.0 26 | secret: 27 | description: 28 | - Name of the secret that contains sensitive data. 29 | type: str 30 | required: true 31 | version_added: 1.6.0 32 | """ 33 | -------------------------------------------------------------------------------- /plugins/doc_fragments/state.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright: (c) 2019, XLAB Steampunk 3 | # 4 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import (absolute_import, division, print_function) 7 | __metaclass__ = type 8 | 9 | 10 | class ModuleDocFragment(object): 11 | DOCUMENTATION = """ 12 | options: 13 | state: 14 | description: 15 | - Target state of the Sensu object. 16 | type: str 17 | choices: [ present, absent ] 18 | default: present 19 | """ 20 | -------------------------------------------------------------------------------- /plugins/filter/backends.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright: (c) 2019, XLAB Steampunk 3 | # 4 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import (absolute_import, division, print_function) 7 | __metaclass__ = type 8 | 9 | DOCUMENTATION = ''' 10 | name: backends 11 | author: Tadej Borovsak (@tadeboro) 12 | version_added: 1.13.2 13 | short_description: Format websocket connection for backends hosts from inventory. 14 | description: 15 | - Socket connection format function. 16 | - Filter backends hosts from ansible inventory groups. 17 | - The return value is a list of websocket connection addresses. 18 | positional: _input 19 | options: 20 | _input: 21 | description: Inventory host variables (hostvars). 22 | type: dict 23 | required: true 24 | groups: 25 | description: List of ansible inventory groups. 26 | type: list 27 | required: true 28 | ''' 29 | 30 | EXAMPLES = ''' 31 | - name: Filter backends from ansible inventory and format a list of websocket connection addresses 32 | ansible.builtin.debug: 33 | msg: "{{ hostvars | sensu.sensu_go.backends(groups) }}" 34 | ''' 35 | 36 | RETURN = ''' 37 | _value: 38 | description: List of websocket connection addresses. 39 | type: list 40 | ''' 41 | 42 | 43 | def _format_backend(vars): 44 | if "api_key_file" in vars: 45 | protocol = "wss" 46 | else: 47 | protocol = "ws" 48 | return "{0}://{1}:{2}".format(protocol, vars["inventory_hostname"], 8081) 49 | 50 | 51 | def backends(hostvars, groups): 52 | return [ 53 | _format_backend(hostvars[name]) for name in groups.get("backends", []) 54 | ] 55 | 56 | 57 | class FilterModule(object): 58 | def filters(self): 59 | return dict( 60 | backends=backends, 61 | ) 62 | -------------------------------------------------------------------------------- /plugins/filter/backends.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # -*- coding: utf-8 -*- 3 | # Copyright: (c) 2020, XLAB Steampunk 4 | # 5 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 6 | 7 | DOCUMENTATION: 8 | name: backends 9 | author: Tadej Borovsak (@tadeboro) 10 | version_added: 1.13.2 11 | short_description: Format websocket connection for backends hosts from inventory. 12 | description: 13 | - Socket connection format function. 14 | - Filter backends hosts from ansible inventory groups. 15 | - The return value is a list of websocket connection addresses. 16 | positional: _input 17 | options: 18 | _input: 19 | description: Inventory host variables (hostvars). 20 | type: dict 21 | required: true 22 | groups: 23 | description: List of ansible inventory groups. 24 | type: list 25 | required: true 26 | 27 | EXAMPLES: | 28 | - name: Filter backends from ansible inventory and format a list of websocket connection addresses 29 | ansible.builtin.debug: 30 | msg: "{{ hostvars | sensu.sensu_go.backends(groups) }}" 31 | 32 | RETURN: 33 | _value: 34 | description: List of websocket connection addresses. 35 | type: list 36 | -------------------------------------------------------------------------------- /plugins/filter/package_name.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright: (c) 2020, XLAB Steampunk 3 | # 4 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import (absolute_import, division, print_function) 7 | __metaclass__ = type 8 | 9 | DOCUMENTATION = ''' 10 | name: package_name 11 | author: Tadej Borovsak (@tadeboro) 12 | version_added: 1.13.2 13 | short_description: Format package name 14 | description: 15 | - Package name format function. 16 | - The return value is a string respresenting package name and build version. 17 | positional: _input 18 | options: 19 | _input: 20 | description: Package type. 21 | choices: [ apt, yum ] 22 | type: string 23 | required: true 24 | name: 25 | description: Package name. 26 | type: string 27 | required: true 28 | version: 29 | description: Package version. 30 | type: string 31 | required: true 32 | build: 33 | description: Package build. 34 | type: string 35 | required: true 36 | ''' 37 | 38 | EXAMPLES = ''' 39 | - name: Install apt component 40 | apt: 41 | name: "{{ 'apt' | sensu.sensu_go.package_name(name, version, build) }}" 42 | 43 | - name: Install yum component 44 | yum: 45 | name: "{{ 'yum' | sensu.sensu_go.package_name(name, version, build) }}" 46 | ''' 47 | 48 | RETURN = ''' 49 | _value: 50 | description: Package name, version and build as a formatted string. 51 | type: string 52 | ''' 53 | 54 | 55 | def _apt_package_name(name, version, build): 56 | if version == "latest": 57 | return name 58 | if build == "latest": 59 | return "{0}={1}-*".format(name, version) 60 | return "{0}={1}-{2}".format(name, version, build) 61 | 62 | 63 | def _yum_package_name(name, version, build): 64 | if version == "latest": 65 | return name 66 | if build == "latest": 67 | return "{0}-{1}".format(name, version) 68 | return "{0}-{1}-{2}".format(name, version, build) 69 | 70 | 71 | KIND_HANDLERS = dict( 72 | apt=_apt_package_name, 73 | yum=_yum_package_name, 74 | ) 75 | 76 | 77 | def package_name(kind, name, version, build): 78 | return KIND_HANDLERS[kind](name, version, build) 79 | 80 | 81 | class FilterModule(object): 82 | def filters(self): 83 | return dict( 84 | package_name=package_name, 85 | ) 86 | -------------------------------------------------------------------------------- /plugins/filter/package_name.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # -*- coding: utf-8 -*- 3 | # Copyright: (c) 2020, XLAB Steampunk 4 | # 5 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 6 | 7 | DOCUMENTATION: 8 | name: package_name 9 | author: Tadej Borovsak (@tadeboro) 10 | version_added: 1.13.2 11 | short_description: Format package name 12 | description: 13 | - Package name format function. 14 | - The return value is a string respresenting package name and build version. 15 | positional: _input 16 | options: 17 | _input: 18 | description: Package type. 19 | choices: [ apt, yum ] 20 | type: string 21 | required: true 22 | name: 23 | description: Package name. 24 | type: string 25 | required: true 26 | version: 27 | description: Package version. 28 | type: string 29 | required: true 30 | build: 31 | description: Package build. 32 | type: string 33 | required: true 34 | 35 | EXAMPLES: | 36 | - name: Install apt component 37 | apt: 38 | name: "{{ 'apt' | sensu.sensu_go.package_name(name, version, build) }}" 39 | 40 | - name: Install yum component 41 | yum: 42 | name: "{{ 'yum' | sensu.sensu_go.package_name(name, version, build) }}" 43 | 44 | RETURN: 45 | _value: 46 | description: Package name, version and build as a formatted string. 47 | type: string 48 | -------------------------------------------------------------------------------- /plugins/module_utils/bonsai.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright: (c) 2019, XLAB Steampunk 3 | # 4 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import absolute_import, division, print_function 7 | __metaclass__ = type 8 | 9 | from . import errors, http 10 | 11 | 12 | def get(path): 13 | url = "https://bonsai.sensu.io/api/v1/assets/{0}".format(path) 14 | resp = http.request("GET", url) 15 | 16 | if resp.status != 200: 17 | raise errors.BonsaiError( 18 | "Server returned status {0}".format(resp.status), 19 | ) 20 | if resp.json is None: 21 | raise errors.BonsaiError("Server returned invalid JSON document") 22 | 23 | return resp.json 24 | 25 | 26 | def get_available_asset_versions(namespace, name): 27 | asset_data = get("{0}/{1}".format(namespace, name)) 28 | try: 29 | return set(v["version"] for v in asset_data["versions"]) 30 | except (TypeError, KeyError): 31 | raise errors.BonsaiError( 32 | "Cannot extract versions from {0}".format(asset_data), 33 | ) 34 | 35 | 36 | def get_asset_version_builds(namespace, name, version): 37 | asset = get("{0}/{1}/{2}/release_asset_builds".format( 38 | namespace, name, version, 39 | )) 40 | if "spec" not in asset or "builds" not in asset["spec"]: 41 | raise errors.BonsaiError("Invalid build spec: {0}".format(asset)) 42 | return asset 43 | 44 | 45 | def get_asset_parameters(name, version): 46 | try: 47 | namespace, asset_name = name.split("/") 48 | except ValueError: 49 | raise errors.BonsaiError( 50 | "Bonsai asset names should be formatted as /.", 51 | ) 52 | 53 | available_versions = get_available_asset_versions(namespace, asset_name) 54 | if version not in available_versions: 55 | raise errors.BonsaiError( 56 | "Version {0} is not available. Choose from: {1}.".format( 57 | version, ", ".join(available_versions), 58 | ), 59 | ) 60 | 61 | asset_builds = get_asset_version_builds(namespace, asset_name, version) 62 | 63 | return dict( 64 | labels=asset_builds.get("metadata", {}).get("labels"), 65 | annotations=asset_builds.get("metadata", {}).get("annotations"), 66 | builds=asset_builds["spec"]["builds"], 67 | ) 68 | -------------------------------------------------------------------------------- /plugins/module_utils/debug.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright: (c) 2019, XLAB Steampunk 3 | # 4 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import absolute_import, division, print_function 7 | __metaclass__ = type 8 | 9 | import os 10 | import tempfile 11 | from datetime import datetime 12 | 13 | 14 | DEBUG = os.environ.get("SENSU_ANSIBLE_DEBUG", "").lower() in ["yes", "true"] 15 | 16 | 17 | def log(message, *args, **kwargs): 18 | """ 19 | Log message to a file (/tmp/sensu-ansible.log) at remote target 20 | 21 | Sensu API returns fairly modest error messages (e.g. when PUT payload contains 22 | unsupported parameter, the error message won't tell you which one) and that 23 | makes it difficult to debug. For that reason we decided to support at least 24 | the most primitive type of logging: write to /tmp/sensu-ansible.log file. 25 | Beware the log file resides on Ansible target and not host because this is 26 | where the module gets executed. 27 | 28 | This function won't do anything unless target has environment variable 29 | SENSU_ANSIBLE_DEBUG set to "yes". When troubleshooting, just set the env 30 | variable in the playbook. 31 | """ 32 | if DEBUG: 33 | with open(os.path.join(tempfile.gettempdir(), "sensu-ansible.log"), "a") as f: 34 | f.write("[{0}]: {1}\n".format(datetime.utcnow(), message.format(*args, **kwargs))) 35 | 36 | 37 | def log_request(method, url, payload, resp=None, comment=None): 38 | """Log API request and response""" 39 | if DEBUG: 40 | if resp: 41 | code, data = resp.status, resp.data 42 | else: 43 | code = data = "?" 44 | fmt = "{0} {1} {2}\nPAYLOAD:{3}\nRESPONSE:{4}\nCOMMENT:{5}" 45 | log(fmt, code, method, url, payload, data, comment) 46 | -------------------------------------------------------------------------------- /plugins/module_utils/errors.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright: (c) 2019, XLAB Steampunk 3 | # 4 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import absolute_import, division, print_function 7 | __metaclass__ = type 8 | 9 | 10 | class Error(Exception): 11 | """ Base error that serves as a parent for all other errors. """ 12 | 13 | 14 | class HttpError(Error): 15 | """ Error that signals failure in HTTP connection. """ 16 | 17 | 18 | class SyncError(Error): 19 | """ Error that signals failure when syncing state with remote. """ 20 | 21 | 22 | class SensuError(Error): 23 | """ Error that signals problems with Sensu Go web API. """ 24 | 25 | 26 | class RequirementsError(Error): 27 | """ Error that signals problems with missing requirements. """ 28 | 29 | 30 | class BonsaiError(Error): 31 | """ Error that signals problems with Bonsai assets. """ 32 | -------------------------------------------------------------------------------- /plugins/module_utils/role_utils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright: (c) 2019, XLAB Steampunk 3 | # 4 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import absolute_import, division, print_function 7 | __metaclass__ = type 8 | 9 | from . import utils 10 | 11 | 12 | def validate_module_params(params): 13 | if params['state'] == 'present': 14 | if not params['rules']: 15 | return 'state is present but all of the following are missing: rules' 16 | return None 17 | 18 | 19 | def validate_binding_module_params(params): 20 | if params["state"] == "present": 21 | if not (params["users"] or params["groups"]): 22 | return 'missing required parameters: users or groups' 23 | 24 | 25 | def type_name_dict(obj_type, name): 26 | return { 27 | 'type': obj_type, 28 | 'name': name, 29 | } 30 | 31 | 32 | def build_subjects(groups, users): 33 | groups_dicts = [type_name_dict('Group', g) for g in (groups or [])] 34 | users_dicts = [type_name_dict('User', u) for u in (users or [])] 35 | 36 | return groups_dicts + users_dicts 37 | 38 | 39 | def do_role_bindings_differ(current, desired): 40 | if _do_subjects_differ(current['subjects'], desired['subjects']): 41 | return True 42 | 43 | return utils.do_differ(current, desired, 'subjects') 44 | 45 | 46 | # sorts a list of subjects (dicts returned by type_name_dict) 47 | # by 'type' and 'name' keys and returns the result of comparison. 48 | def _do_subjects_differ(a, b): 49 | sorted_a = sorted(a, key=lambda x: (x['type'], x['name'])) 50 | sorted_b = sorted(b, key=lambda x: (x['type'], x['name'])) 51 | return sorted_a != sorted_b 52 | 53 | 54 | def _rule_set(rules): 55 | return set( 56 | ( 57 | frozenset(r.get('verbs', []) or []), 58 | frozenset(r.get('resources', []) or []), 59 | frozenset(r.get('resource_names', []) or []) 60 | ) for r in rules 61 | ) 62 | 63 | 64 | def _do_rules_differ(current_rules, desired_rules): 65 | if len(current_rules) != len(desired_rules): 66 | return True 67 | if _rule_set(current_rules) != _rule_set(desired_rules): 68 | return True 69 | return False 70 | 71 | 72 | def do_roles_differ(current, desired): 73 | if _do_rules_differ(current['rules'], desired['rules']): 74 | return True 75 | 76 | return utils.do_differ(current, desired, 'rules') 77 | -------------------------------------------------------------------------------- /plugins/modules/namespace_info.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # Copyright: (c) 2019, Paul Arthur 4 | # 5 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 6 | 7 | from __future__ import absolute_import, division, print_function 8 | __metaclass__ = type 9 | 10 | ANSIBLE_METADATA = { 11 | "metadata_version": "1.1", 12 | "status": ["stableinterface"], 13 | "supported_by": "certified", 14 | } 15 | 16 | DOCUMENTATION = ''' 17 | module: namespace_info 18 | author: 19 | - Paul Arthur (@flowerysong) 20 | - Aljaz Kosir (@aljazkosir) 21 | - Miha Plesko (@miha-plesko) 22 | - Tadej Borovsak (@tadeboro) 23 | short_description: List Sensu namespaces 24 | description: 25 | - Retrieve information about Sensu namespaces. 26 | - For more information, refer to the Sensu documentation at 27 | U(https://docs.sensu.io/sensu-go/latest/reference/rbac/#namespaces). 28 | version_added: 1.0.0 29 | extends_documentation_fragment: 30 | - sensu.sensu_go.requirements 31 | - sensu.sensu_go.auth 32 | notes: 33 | - Currently, it is not possible to retrieve information about a single 34 | namespace because namespace is not much more than a name itself. 35 | seealso: 36 | - module: sensu.sensu_go.namespace 37 | ''' 38 | 39 | EXAMPLES = ''' 40 | - name: List Sensu namespaces 41 | sensu.sensu_go.namespace_info: 42 | register: result 43 | ''' 44 | 45 | RETURN = ''' 46 | objects: 47 | description: List of Sensu namespaces. 48 | returned: success 49 | type: list 50 | elements: dict 51 | sample: 52 | - name: default 53 | ''' 54 | 55 | from ansible.module_utils.basic import AnsibleModule 56 | 57 | from ..module_utils import arguments, errors, utils 58 | 59 | 60 | def main(): 61 | module = AnsibleModule( 62 | supports_check_mode=True, 63 | argument_spec=dict( 64 | arguments.get_spec("auth"), 65 | ), 66 | ) 67 | client = arguments.get_sensu_client(module.params['auth']) 68 | path = utils.build_core_v2_path(None, 'namespaces') 69 | 70 | try: 71 | namespaces = utils.get(client, path) 72 | except errors.Error as e: 73 | module.fail_json(msg=str(e)) 74 | 75 | module.exit_json(changed=False, objects=namespaces) 76 | 77 | 78 | if __name__ == '__main__': 79 | main() 80 | -------------------------------------------------------------------------------- /pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | junit_family = xunit1 3 | -------------------------------------------------------------------------------- /roles/agent/README.md: -------------------------------------------------------------------------------- 1 | # sensu.sensu_go.agent role 2 | 3 | Visit [the official documentation site][docs] for role documentation. 4 | 5 | [docs]: https://sensu.github.io/sensu-go-ansible/roles/agent.html 6 | -------------------------------------------------------------------------------- /roles/agent/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Related to /etc/sensu/backend.yml, see 3 | # https://docs.sensu.io/sensu-go/latest/reference/agent/#configuration-summary 4 | agent_backend_urls: "{{ hostvars | sensu.sensu_go.backends(groups) }}" 5 | agent_config: 6 | -------------------------------------------------------------------------------- /roles/agent/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Restart Linux agent 3 | ansible.builtin.service: 4 | name: sensu-agent 5 | state: restarted 6 | when: manage_sensu_agent_service | default(False) 7 | 8 | - name: Restart Windows agent 9 | action: 10 | module: ansible.windows.win_service 11 | name: SensuAgent 12 | state: restarted 13 | when: manage_sensu_agent_service | default(False) 14 | 15 | # You probably noticed that we use some black magic in the previous handler. 16 | # Let us explain what it does and why did we bring it into the daylight. 17 | # 18 | # Under normal circumstances, we would write the previous handler as 19 | # 20 | # - name: Restart Windows agent 21 | # win_service: 22 | # name: SensuAgent 23 | # state: restarted 24 | # 25 | # When Ansible loads this handler, it makes sure it can find the win_service 26 | # module. And this is where things start to go downhill for us. Because we do 27 | # not have a guarantee that win_service module will be available (win_service 28 | # is not part of a certified collection), this eagerness prevents operating in 29 | # certain situations where win_service module is not even needed. 30 | # 31 | # And this is why we use the alternative form that forces Ansible to lazy-load 32 | # the module at the task/handler execution time. 33 | # 34 | # Of course, it would be much easier if we could declare ansible.windows as our 35 | # dependency, but this is not possible at the moment. 36 | -------------------------------------------------------------------------------- /roles/agent/meta/argument_specs.yml: -------------------------------------------------------------------------------- 1 | argument_specs: 2 | 3 | configure: 4 | short_description: Configure Sensu Go agent 5 | description: 6 | - Write the Sensu Go agent configuration file. 7 | 8 | options: 9 | agent_config: &agent_config 10 | description: 11 | - Any option that is valid for the Sensu Go agent version we are 12 | installing. 13 | - All valid options are listed at 14 | U(https://docs.sensu.io/sensu-go/latest/reference/agent/#configuration). 15 | - Role copies the key-value pairs from the I(agent_config) variable 16 | verbatim to the configuration file. This means that we must copy 17 | the key names B(exactly) as they appear in the configuration 18 | reference. In a way, the I(agent_config) variable should contain a 19 | properly indented copy of the C(/etc/sensu/agent.yml) file. 20 | type: dict 21 | 22 | start: 23 | short_description: Start Sensu Go agent 24 | description: 25 | - Start the Sensu Go agent service. 26 | options: {} 27 | 28 | main: 29 | short_description: Install, configure, and start Sensu Go agent 30 | description: 31 | - Install, configure, and start the Sensu Go agent service. 32 | 33 | options: 34 | channel: 35 | description: 36 | - Repository channel that serves as a source of packages. 37 | - Visit the packagecloud site to find all available channels. 38 | type: str 39 | default: stable 40 | 41 | version: &version 42 | description: 43 | - Package version to install. 44 | - Can be any valid version string such as C(6.2.5) or special value 45 | C(latest). 46 | type: str 47 | default: latest 48 | 49 | build: 50 | description: 51 | - Package build to install. 52 | - Can be any valid build string such as C(8290) or a special value 53 | latest. 54 | - If the I(version) variable is set to latest, this variable is 55 | ignored and the latest available build is installed. 56 | type: str 57 | default: latest 58 | 59 | agent_config: *agent_config 60 | -------------------------------------------------------------------------------- /roles/agent/meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: XLAB Steampunk 3 | description: Configure Sensu Go agent 4 | license: GPL-3.0-or-later 5 | min_ansible_version: "2.8" 6 | 7 | platforms: 8 | - name: EL 9 | versions: 10 | - "7" 11 | - "8" 12 | - name: Ubuntu 13 | versions: 14 | - trusty 15 | - xenial 16 | - bionic 17 | - disco 18 | - name: Debian 19 | versions: 20 | - stretch 21 | - buster 22 | 23 | galaxy_tags: 24 | - sensu 25 | -------------------------------------------------------------------------------- /roles/agent/tasks/configure.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Configure agent (Linux) 3 | ansible.builtin.include_tasks: linux/configure.yml 4 | when: ansible_facts.os_family != "Windows" 5 | 6 | - name: Configure agent (Windows) 7 | ansible.builtin.include_tasks: windows/configure.yml 8 | when: ansible_facts.os_family == "Windows" 9 | -------------------------------------------------------------------------------- /roles/agent/tasks/linux/configure.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Load Linux locations 3 | ansible.builtin.include_vars: linux.yml 4 | 5 | - name: Install agent communication PKI 6 | ansible.builtin.copy: 7 | src: "{{ agent_trusted_ca_file }}" 8 | dest: "{{ trusted_ca_file_path }}" 9 | # Keep this in sync with what the backend service is running as from packager 10 | owner: &sensu_user sensu 11 | group: &sensu_group sensu 12 | mode: "0644" 13 | when: agent_trusted_ca_file is defined 14 | 15 | - name: Configure sensu-agent ({{ agent_config_path }}) 16 | ansible.builtin.template: 17 | src: agent.yml.j2 18 | dest: "{{ agent_config_path }}" 19 | owner: *sensu_user 20 | group: *sensu_group 21 | mode: '0600' 22 | notify: Restart Linux agent 23 | -------------------------------------------------------------------------------- /roles/agent/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install sensu-go-agent binary 3 | ansible.builtin.include_role: 4 | name: install 5 | vars: 6 | components: [sensu-go-agent] # noqa: var-naming[no-role-prefix] 7 | 8 | - name: Inform restart handler that we are in charge of the agent service 9 | ansible.builtin.set_fact: 10 | manage_sensu_agent_service: true 11 | 12 | - name: Configure the agent 13 | ansible.builtin.include_tasks: configure.yml 14 | 15 | - name: Start the agent 16 | ansible.builtin.include_tasks: start.yml 17 | -------------------------------------------------------------------------------- /roles/agent/tasks/start.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Start sensu-agent (Linux) 3 | ansible.builtin.service: 4 | name: sensu-agent 5 | state: started 6 | enabled: true 7 | when: ansible_facts.os_family != "Windows" 8 | 9 | - name: Start sensu-agent (Windows) 10 | action: 11 | module: ansible.windows.win_service 12 | name: SensuAgent 13 | path: C:\Program Files\sensu\sensu-agent\bin\sensu-agent.exe service run 14 | state: started 15 | when: ansible_facts.os_family == "Windows" 16 | -------------------------------------------------------------------------------- /roles/agent/tasks/windows/configure.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Load Windows locations 3 | ansible.builtin.include_vars: windows.yml 4 | 5 | - name: Install agent communication PKI 6 | ansible.windows.win_copy: 7 | src: "{{ agent_trusted_ca_file }}" 8 | dest: "{{ trusted_ca_file_path }}" 9 | when: agent_trusted_ca_file is defined 10 | 11 | - name: Configure sensu-agent ({{ agent_config_path }}) 12 | ansible.windows.win_template: 13 | src: agent.yml.j2 14 | dest: "{{ agent_config_path }}" 15 | notify: Restart Windows agent 16 | -------------------------------------------------------------------------------- /roles/agent/templates/agent.yml.j2: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # {{ managed }} 4 | # 5 | 6 | ## 7 | # Sensu agent configuration 8 | ## 9 | {% if not agent_config or "backend-url" not in agent_config %} 10 | backend-url: 11 | {{ agent_backend_urls | to_nice_yaml }} 12 | {% endif -%} 13 | 14 | {% if agent_trusted_ca_file is defined and 15 | not (agent_config and "trusted-ca-file" in agent_config) %} 16 | trusted-ca-file: {{ trusted_ca_file_path }} 17 | {% endif -%} 18 | 19 | {% if agent_trusted_ca_file is defined or agent_config and 20 | ("trusted-ca-file" in agent_config and 21 | not "insecure-skip-tls-verify" in agent_config) %} 22 | insecure-skip-tls-verify: false 23 | {% endif -%} 24 | 25 | {% if agent_config %} 26 | {{ agent_config | to_nice_yaml }} 27 | {% endif %} 28 | -------------------------------------------------------------------------------- /roles/agent/vars/linux.yml: -------------------------------------------------------------------------------- 1 | --- 2 | agent_config_path: /etc/sensu/agent.yml 3 | trusted_ca_file_path: /etc/sensu/sensu-agent-trusted-ca.crt 4 | -------------------------------------------------------------------------------- /roles/agent/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | managed: Managed by Ansible - do NOT edit this file manually! 3 | -------------------------------------------------------------------------------- /roles/agent/vars/windows.yml: -------------------------------------------------------------------------------- 1 | --- 2 | agent_config_path: C:\ProgramData\sensu\config\agent.yml 3 | trusted_ca_file_path: C:\ProgramData\sensu\config\sensu-agent-trusted-ca.crt 4 | -------------------------------------------------------------------------------- /roles/backend/README.md: -------------------------------------------------------------------------------- 1 | # sensu.sensu_go.backend role 2 | 3 | Visit [the official documentation site][docs] for role documentation. 4 | 5 | [docs]: https://sensu.github.io/sensu-go-ansible/roles/backend.html 6 | -------------------------------------------------------------------------------- /roles/backend/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | cluster_admin_username: admin 3 | cluster_admin_password: P@ssw0rd! 4 | 5 | # Related to /etc/sensu/backend.yml, see 6 | # https://docs.sensu.io/sensu-go/latest/reference/backend/#configuration-summary 7 | backend_config: 8 | -------------------------------------------------------------------------------- /roles/backend/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Restart backend 3 | ansible.builtin.service: 4 | name: sensu-backend 5 | state: restarted 6 | when: manage_sensu_backend_service | default(False) 7 | -------------------------------------------------------------------------------- /roles/backend/meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: XLAB Steampunk 3 | description: Configure Sensu Go backend 4 | license: GPL-3.0-or-later 5 | min_ansible_version: "2.8" 6 | 7 | platforms: 8 | - name: EL 9 | versions: 10 | - "7" 11 | - "8" 12 | - name: Ubuntu 13 | versions: 14 | - trusty 15 | - xenial 16 | - bionic 17 | - disco 18 | - name: Debian 19 | versions: 20 | - stretch 21 | - buster 22 | 23 | galaxy_tags: 24 | - sensu 25 | -------------------------------------------------------------------------------- /roles/backend/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install sensu-go-backend binary 3 | ansible.builtin.include_role: 4 | name: install 5 | vars: 6 | components: [sensu-go-backend] # noqa: var-naming[no-role-prefix] 7 | 8 | - name: Inform restart handler that we are in charge of the backend service 9 | ansible.builtin.set_fact: 10 | manage_sensu_backend_service: true 11 | 12 | - name: Configure the backend 13 | ansible.builtin.include_tasks: configure.yml 14 | 15 | - name: Start the backend 16 | ansible.builtin.include_tasks: start.yml 17 | -------------------------------------------------------------------------------- /roles/backend/tasks/start.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Start sensu-backend 3 | ansible.builtin.service: 4 | name: sensu-backend 5 | state: started 6 | enabled: true 7 | 8 | - name: Check for sensu-backend init command 9 | ansible.builtin.command: 10 | cmd: sensu-backend init -h 11 | register: init_command_test 12 | failed_when: false # Never fail, we just want to know if init exists. 13 | changed_when: false # Displaying help is read-only operation. 14 | check_mode: false # We do not modify the system, so we can always run 15 | 16 | - name: Initialize backend 17 | ansible.builtin.command: 18 | cmd: sensu-backend init 19 | environment: 20 | SENSU_BACKEND_CLUSTER_ADMIN_USERNAME: "{{ cluster_admin_username }}" 21 | SENSU_BACKEND_CLUSTER_ADMIN_PASSWORD: "{{ cluster_admin_password }}" 22 | when: init_command_test.rc == 0 23 | register: init_command 24 | failed_when: init_command.rc not in (0, 3) # 0 - OK, 3 - already initialized 25 | changed_when: init_command.rc == 0 26 | -------------------------------------------------------------------------------- /roles/backend/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | managed: Managed by Ansible - do NOT edit this file manually! 3 | -------------------------------------------------------------------------------- /roles/install/README.md: -------------------------------------------------------------------------------- 1 | # sensu.sensu_go.install role 2 | 3 | Visit [the official documentation site][docs] for role documentation. 4 | 5 | [docs]: https://sensu.github.io/sensu-go-ansible/roles/install.html 6 | -------------------------------------------------------------------------------- /roles/install/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | os: unknown 3 | dist: unknown 4 | 5 | packagecloud_auth: "" 6 | channel: stable 7 | version: latest 8 | build: latest 9 | components: 10 | - sensu-go-backend 11 | - sensu-go-agent 12 | - sensu-go-cli 13 | -------------------------------------------------------------------------------- /roles/install/meta/argument_specs.yml: -------------------------------------------------------------------------------- 1 | argument_specs: 2 | 3 | repositories: 4 | short_description: Enable Sensu Go repos 5 | description: 6 | - Install required repository files on supported distributions. 7 | - This entry point does not work on Windows because there is no 8 | concept of repository there. 9 | 10 | options: 11 | channel: &channel 12 | description: 13 | - Repository channel that serves as a source of packages. 14 | - Visit the packagecloud site to find all available channels. 15 | type: str 16 | default: stable 17 | 18 | packages: 19 | short_description: Install selected Sensu Go packages 20 | description: 21 | - Make sure selected packages are installed. 22 | - By default, the role will install latest available package version. 23 | This will change in the next major version of the collection where the 24 | I(version) will become a required variable. 25 | 26 | options: 27 | components: &components 28 | description: 29 | - List of components to install. 30 | type: list 31 | elements: str 32 | choices: 33 | - sensu-go-backend 34 | - sensu-go-agent 35 | - sensu-go-cli 36 | default: 37 | - sensu-go-backend 38 | - sensu-go-agent 39 | - sensu-go-cli 40 | 41 | version: &version 42 | description: 43 | - Package version to install. 44 | - Can be any valid version string such as C(6.2.5) or special value 45 | C(latest). 46 | type: str 47 | default: latest 48 | 49 | build: &build 50 | description: 51 | - Package build to install. 52 | - Can be any valid build string such as C(8290) or a special value 53 | latest. 54 | - If the I(version) variable is set to latest, this variable is 55 | ignored and the latest available build is installed. 56 | type: str 57 | default: latest 58 | 59 | main: 60 | short_description: Enable Sensu Go repos and install selected packages 61 | description: 62 | - The main entry point just combines the repositories and packages entry 63 | points. 64 | 65 | options: 66 | components: *components 67 | channel: *channel 68 | version: *version 69 | build: *build 70 | -------------------------------------------------------------------------------- /roles/install/meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: XLAB Steampunk 3 | description: Install Sensu Go components 4 | license: GPL-3.0-or-later 5 | min_ansible_version: "2.8" 6 | 7 | platforms: 8 | - name: EL 9 | versions: 10 | - "7" 11 | - "8" 12 | - name: Ubuntu 13 | versions: 14 | - trusty 15 | - xenial 16 | - bionic 17 | - disco 18 | - name: Debian 19 | versions: 20 | - stretch 21 | - buster 22 | 23 | galaxy_tags: 24 | - sensu 25 | -------------------------------------------------------------------------------- /roles/install/tasks/apt/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install component 3 | ansible.builtin.apt: 4 | name: "{{ 'apt' | sensu.sensu_go.package_name(item, version, build) }}" 5 | state: "{{ (version == 'latest') | ternary('latest', 'present') }}" 6 | # FIXME(@tadeboro): This is a temporary "fix" for 7 | # https://github.com/ansible/ansible/issues/29451. 8 | force: true 9 | loop: "{{ components }}" 10 | -------------------------------------------------------------------------------- /roles/install/tasks/apt/prepare.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Include distro-specific vars ({{ ansible_distribution }}) 3 | ansible.builtin.include_vars: 4 | file: '{{ ansible_distribution }}.yml' 5 | 6 | - name: Update sources.list file 7 | ansible.builtin.shell: echo "deb http://archive.debian.org/debian stretch main contrib non-free" > /etc/apt/sources.list 8 | when: ansible_distribution == 'Debian' and ansible_distribution_major_version == '9' 9 | changed_when: false 10 | 11 | - name: Update apt cache (ensure we have package index) 12 | ansible.builtin.apt: 13 | update_cache: true 14 | # Updating the APT cache does not change the system so we never report a 15 | # change here (helps keep the role idempotent). 16 | changed_when: false 17 | 18 | - name: Install utility packages 19 | ansible.builtin.apt: 20 | name: 21 | - gnupg 22 | - debian-archive-keyring 23 | - apt-transport-https 24 | state: present 25 | 26 | - name: Fetch the apt repository key 27 | ansible.builtin.uri: 28 | url: https://{{ packagecloud_auth }}packagecloud.io/sensu/{{ channel }}/gpgkey 29 | force_basic_auth: true 30 | return_content: true 31 | register: apt_key_download 32 | # Fetching resource into memory does not change the system at all, so we 33 | # never report a change here (helps keep the role idempotent). And by the 34 | # same line of reasoning, we are also safe to run in check mode (the uri 35 | # module does not support check mode and would cause us grief when it would 36 | # be skipped). 37 | changed_when: false 38 | check_mode: false 39 | 40 | - name: Add apt key 41 | ansible.builtin.apt_key: 42 | data: "{{ apt_key_download.content }}" 43 | 44 | - name: Add apt repository 45 | ansible.builtin.apt_repository: 46 | repo: deb https://{{ packagecloud_auth }}packagecloud.io/sensu/{{ channel }}/{{ os }}/ {{ dist }} main 47 | filename: /etc/apt/sources.list.d/sensu_{{ channel }} 48 | validate_certs: true 49 | 50 | - name: Add apt source repository 51 | ansible.builtin.apt_repository: 52 | repo: deb-src https://{{ packagecloud_auth }}packagecloud.io/sensu/{{ channel }}/{{ os }}/ {{ dist }} main 53 | filename: /etc/apt/sources.list.d/sensu_{{ channel }} 54 | validate_certs: true 55 | -------------------------------------------------------------------------------- /roles/install/tasks/dnf/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Why did we kill the package-latest check? Because we really do want to be 3 | # able to upgrade the packages to the latest stable version. 4 | - name: Install component 5 | ansible.builtin.dnf: 6 | name: "{{ 'yum' | sensu.sensu_go.package_name(item, version, build) }}" 7 | state: latest # noqa package-latest 8 | allow_downgrade: true 9 | loop: "{{ components }}" 10 | -------------------------------------------------------------------------------- /roles/install/tasks/dnf/prepare.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Include distro-specific vars ({{ ansible_distribution }}) 3 | ansible.builtin.include_vars: 4 | file: '{{ ansible_distribution }}.yml' 5 | 6 | - name: Add yum repository 7 | ansible.builtin.yum_repository: 8 | name: sensu_{{ channel }} 9 | description: sensu_{{ channel }} 10 | file: sensu 11 | baseurl: https://{{ packagecloud_auth }}packagecloud.io/sensu/{{ channel }}/{{ os }}/{{ dist }}/$basearch 12 | gpgkey: https://{{ packagecloud_auth }}packagecloud.io/sensu/{{ channel }}/gpgkey 13 | gpgcheck: false 14 | repo_gpgcheck: true 15 | enabled: true 16 | sslverify: true 17 | sslcacert: /etc/pki/tls/certs/ca-bundle.crt 18 | metadata_expire: '300' 19 | 20 | - name: Add yum source repository 21 | ansible.builtin.yum_repository: 22 | name: sensu_{{ channel }}-source 23 | description: sensu_{{ channel }}-source 24 | file: sensu 25 | baseurl: https://{{ packagecloud_auth }}packagecloud.io/sensu/{{ channel }}/{{ os }}/{{ dist }}/SRPMS 26 | gpgkey: https://{{ packagecloud_auth }}packagecloud.io/sensu/{{ channel }}/gpgkey 27 | gpgcheck: false 28 | repo_gpgcheck: true 29 | enabled: true 30 | sslverify: true 31 | sslcacert: /etc/pki/tls/certs/ca-bundle.crt 32 | metadata_expire: '300' 33 | -------------------------------------------------------------------------------- /roles/install/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Prepare package repositories 3 | ansible.builtin.include_tasks: repositories.yml 4 | when: ansible_facts.os_family != "Windows" # No repo concept on Windows 5 | 6 | - name: Install selected packages 7 | ansible.builtin.include_tasks: packages.yml 8 | -------------------------------------------------------------------------------- /roles/install/tasks/msi/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Make sure we are installing agent 3 | ansible.builtin.assert: 4 | that: 5 | - components | length == 1 6 | - components.0 == "sensu-go-agent" 7 | fail_msg: Windows hosts only support agent installation 8 | quiet: true 9 | 10 | - name: Load supported agent versions on Windows 11 | ansible.builtin.include_vars: 12 | file: Windows.yml 13 | 14 | - name: Check if version is supported 15 | ansible.builtin.assert: 16 | that: 17 | - version in _msi_lookup 18 | fail_msg: Version {{ version }} is not supported 19 | quiet: true 20 | 21 | - name: Set version, build, and arch 22 | ansible.builtin.set_fact: 23 | _version: "{{ _msi_lookup[version].version }}" 24 | _build: "{{ _msi_lookup[version].build }}" 25 | _arch: "{{ (ansible_facts.architecture == '64-bit') | ternary('x64', 'x86') }}" 26 | 27 | - name: Fetch product code 28 | ansible.builtin.set_fact: 29 | _product_code: "{{ _msi_lookup[_version].product_codes[_arch] }}" 30 | 31 | - name: Install component 32 | ansible.windows.win_package: 33 | path: "https://s3-us-west-2.amazonaws.com/sensu.io/sensu-go/{{ _version }}\ 34 | /sensu-go-agent_{{ _version }}.{{ _build }}_en-US.{{ _arch }}.msi" 35 | product_id: "{{ _product_code }}" 36 | -------------------------------------------------------------------------------- /roles/install/tasks/packages.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install selected components (Linux) 3 | ansible.builtin.include_tasks: "{{ ansible_pkg_mgr }}/install.yml" 4 | when: ansible_facts.os_family != "Windows" 5 | 6 | - name: Install selected components (Windows) 7 | ansible.builtin.include_tasks: "msi/install.yml" 8 | when: ansible_facts.os_family == "Windows" 9 | -------------------------------------------------------------------------------- /roles/install/tasks/repositories.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Prepare package repositories 3 | ansible.builtin.include_tasks: "{{ ansible_pkg_mgr }}/prepare.yml" 4 | -------------------------------------------------------------------------------- /roles/install/tasks/yum/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Why did we kill the package-latest check? Because we really do want to be 3 | # able to upgrade the packages to the latest stable version. 4 | - name: Install component 5 | ansible.builtin.yum: 6 | name: "{{ 'yum' | sensu.sensu_go.package_name(item, version, build) }}" 7 | state: "{{ (version == 'latest') | ternary('latest', 'present') }}" 8 | allow_downgrade: true 9 | loop: "{{ components }}" 10 | -------------------------------------------------------------------------------- /roles/install/tasks/yum/prepare.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Include distro-specific vars ({{ ansible_distribution }}) 3 | ansible.builtin.include_vars: 4 | file: '{{ ansible_distribution }}.yml' 5 | 6 | - name: Add yum repository 7 | ansible.builtin.yum_repository: 8 | name: sensu_{{ channel }} 9 | description: sensu_{{ channel }} 10 | file: sensu 11 | baseurl: https://{{ packagecloud_auth }}packagecloud.io/sensu/{{ channel }}/{{ os }}/{{ dist }}/$basearch 12 | gpgkey: https://{{ packagecloud_auth }}packagecloud.io/sensu/{{ channel }}/gpgkey 13 | gpgcheck: false 14 | repo_gpgcheck: true 15 | enabled: true 16 | sslverify: true 17 | sslcacert: /etc/pki/tls/certs/ca-bundle.crt 18 | metadata_expire: '300' 19 | 20 | - name: Add yum source repository 21 | ansible.builtin.yum_repository: 22 | name: sensu_{{ channel }}-source 23 | description: sensu_{{ channel }}-source 24 | file: sensu 25 | baseurl: https://{{ packagecloud_auth }}packagecloud.io/sensu/{{ channel }}/{{ os }}/{{ dist }}/SRPMS 26 | gpgkey: https://{{ packagecloud_auth }}packagecloud.io/sensu/{{ channel }}/gpgkey 27 | gpgcheck: false 28 | repo_gpgcheck: true 29 | enabled: true 30 | sslverify: true 31 | sslcacert: /etc/pki/tls/certs/ca-bundle.crt 32 | metadata_expire: '300' 33 | -------------------------------------------------------------------------------- /roles/install/vars/Alma.yml: -------------------------------------------------------------------------------- 1 | --- 2 | os: el 3 | dist: '{{ ansible_distribution_version.split(".")[0] }}' 4 | -------------------------------------------------------------------------------- /roles/install/vars/AlmaLinux.yml: -------------------------------------------------------------------------------- 1 | Alma.yml -------------------------------------------------------------------------------- /roles/install/vars/Amazon.yml: -------------------------------------------------------------------------------- 1 | --- 2 | os: el 3 | dist: 6 4 | -------------------------------------------------------------------------------- /roles/install/vars/CentOS.yml: -------------------------------------------------------------------------------- 1 | --- 2 | os: el 3 | dist: '{{ ansible_distribution_version.split(".")[0] }}' 4 | -------------------------------------------------------------------------------- /roles/install/vars/Debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | os: debian 3 | dist: '{{ ansible_distribution_release }}' 4 | -------------------------------------------------------------------------------- /roles/install/vars/OracleLinux.yml: -------------------------------------------------------------------------------- 1 | CentOS.yml -------------------------------------------------------------------------------- /roles/install/vars/RedHat.yml: -------------------------------------------------------------------------------- 1 | CentOS.yml -------------------------------------------------------------------------------- /roles/install/vars/Rocky.yml: -------------------------------------------------------------------------------- 1 | --- 2 | os: el 3 | dist: '{{ ansible_distribution_version.split(".")[0] }}' 4 | -------------------------------------------------------------------------------- /roles/install/vars/Ubuntu.yml: -------------------------------------------------------------------------------- 1 | --- 2 | os: ubuntu 3 | dist: '{{ ansible_distribution_release }}' 4 | -------------------------------------------------------------------------------- /sanity.requirements: -------------------------------------------------------------------------------- 1 | # ansible-lint >= 4.3.0 does not support python < 3.6 anymore 2 | ansible-lint==6.18.0; python_version >= "3.10" 3 | ansible-lint==5.4.0; python_version < "3.10" 4 | flake8 5 | yamllint 6 | pyyaml 7 | requests 8 | -------------------------------------------------------------------------------- /tests/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | modules: 3 | python_requires: ">= 2.7" 4 | -------------------------------------------------------------------------------- /tests/integration/base.yml: -------------------------------------------------------------------------------- 1 | --- 2 | scenario: 3 | test_sequence: 4 | - destroy 5 | - create 6 | - converge 7 | - destroy 8 | dependency: 9 | name: galaxy 10 | driver: 11 | name: docker 12 | provisioner: 13 | name: ansible 14 | config_options: 15 | defaults: 16 | interpreter_python: auto_silent 17 | lint: 18 | enabled: false 19 | platforms: 20 | - name: v6.10.0 21 | image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.10.0 22 | pre_build_image: true 23 | pull: true 24 | override_command: false 25 | - name: v6.9.0 26 | image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.9.0 27 | pre_build_image: true 28 | pull: true 29 | override_command: false 30 | - name: v6.8.2 31 | image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.8.2 32 | pre_build_image: true 33 | pull: true 34 | override_command: false 35 | - name: v6.7.5 36 | image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.7.5 37 | pre_build_image: true 38 | pull: true 39 | override_command: false 40 | - name: v6.6.2 41 | image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.6.2 42 | pre_build_image: true 43 | pull: true 44 | override_command: false 45 | - name: v6.5.5 46 | image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.5.5 47 | pre_build_image: true 48 | pull: true 49 | override_command: false 50 | - name: v6.4.3 51 | image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.4.3 52 | pre_build_image: true 53 | pull: true 54 | override_command: false 55 | - name: v6.3.0 56 | image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.3.0 57 | pre_build_image: true 58 | pull: true 59 | override_command: false 60 | -------------------------------------------------------------------------------- /tests/integration/molecule/action_bonsai_asset/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/action_bonsai_asset/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/misc_api_authentication/molecule.yml: -------------------------------------------------------------------------------- 1 | platforms: 2 | - name: v6.4.1 3 | image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.4.1 4 | groups: [has_api_key_support] 5 | pre_build_image: true 6 | pull: true 7 | override_command: false 8 | - name: v5.14.2 9 | image: quay.io/xlab-steampunk/sensu-go-tests-sensu:5.14.2 10 | groups: [no_api_key_support] 11 | pre_build_image: true 12 | pull: true 13 | override_command: false 14 | -------------------------------------------------------------------------------- /tests/integration/molecule/misc_api_cert/converge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: all 4 | gather_facts: false 5 | 6 | tasks: 7 | - name: Test connection using no verification 8 | sensu.sensu_go.asset_info: 9 | auth: 10 | url: https://localhost:8080 11 | verify: false 12 | 13 | - name: Test connection using no verification (env var) 14 | sensu.sensu_go.asset_info: 15 | auth: 16 | url: https://localhost:8080 17 | environment: 18 | SENSU_VERIFY: "false" 19 | 20 | - name: Test connection using custom CA 21 | sensu.sensu_go.user_info: 22 | auth: 23 | url: https://sensu-api:8080 24 | ca_path: /etc/sensu/api-ca.crt 25 | 26 | - name: Test connection using custom CA (env var) 27 | sensu.sensu_go.user_info: 28 | auth: 29 | url: https://sensu-api:8080 30 | environment: 31 | SENSU_CA_PATH: /etc/sensu/api-ca.crt 32 | 33 | - name: Test connection using default verification 34 | sensu.sensu_go.asset_info: 35 | auth: 36 | url: https://localhost:8080 37 | ignore_errors: true 38 | register: result 39 | 40 | - assert: 41 | that: 42 | - result is failed 43 | - '"certificate" in result.msg' 44 | 45 | - name: Test connection using custom CA not matching name 46 | sensu.sensu_go.user_info: 47 | auth: 48 | url: https://localhost:8080 49 | ca_path: /etc/sensu/api-ca.crt 50 | ignore_errors: true 51 | register: result 52 | 53 | - assert: 54 | that: 55 | - result is failed 56 | - result.msg is search("localhost.+sensu-api") 57 | 58 | - name: Test connection using the wrong protocol 59 | sensu.sensu_go.asset_info: 60 | auth: 61 | url: http://localhost:8080 62 | ignore_errors: true 63 | register: result 64 | 65 | - assert: 66 | that: 67 | - result is failed 68 | -------------------------------------------------------------------------------- /tests/integration/molecule/misc_api_cert/files/regenerate_cert.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Generate root CA certificate 4 | openssl genrsa -out sensu-api-ca.key 2048 5 | openssl req -x509 -sha256 -new -nodes -key sensu-api-ca.key -subj '/CN=Sensu-test CA' -days 1095 -out sensu-api-ca.crt 6 | 7 | # Generate certificate 8 | openssl genrsa -out sensu-api.key 2048 9 | openssl req -new -key "sensu-api.key" -out "sensu-api.csr" -sha256 -subj '/CN=sensu-api' 10 | openssl x509 -req -days 1095 -in "sensu-api.csr" -sha256 -CA "sensu-api-ca.crt" -CAkey "sensu-api-ca.key" -CAcreateserial -out "sensu-api.crt" -extfile "sensu-api.cnf" -extensions server 11 | 12 | # print content of certificate 13 | openssl x509 -in sensu-api-ca.crt -text 14 | openssl x509 -in sensu-api.crt -text -------------------------------------------------------------------------------- /tests/integration/molecule/misc_api_cert/files/sensu-api-ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDETCCAfmgAwIBAgIUBSnmUh6PCEF3/6zTJ1DqH9rcNuswDQYJKoZIhvcNAQEL 3 | BQAwGDEWMBQGA1UEAwwNU2Vuc3UtdGVzdCBDQTAeFw0yMjEyMTIwNjQ3NDdaFw0y 4 | NTEyMTEwNjQ3NDdaMBgxFjAUBgNVBAMMDVNlbnN1LXRlc3QgQ0EwggEiMA0GCSqG 5 | SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCoAXA7t1aC4zNgZNCasPHxcyCfmC4J5zoh 6 | oTstyiFxhNv131EEQtpIABcWsgDXtQozJuAgHTVuGHEbHlFu7BFrh9Ik6FEznuZW 7 | pZ53V//LRtQZt7DLQrJP2ZJhGedSm+exZj8f0Uk8do0xI46BtwT/u5pzkLN8NLCk 8 | z+xu2mnFN+pdTqJLHP59JpRV1E0Al2E1m9rCfR8grGh4lTFDE/SwUueaHmg5Z0TN 9 | QuROuRii1HcK8g7QZ0HyOWRGfpNGzXq2kYUaGTvONrSwGe4bPjT/Jp4TElUV9mSA 10 | YoBE6JaDi1v28sXD9Cz6JgK63Ci0lmz6ny3H7kNfMQECgpj3KWL7AgMBAAGjUzBR 11 | MB0GA1UdDgQWBBQrUp514z1VOH+uWKjmtkvomGULLjAfBgNVHSMEGDAWgBQrUp51 12 | 4z1VOH+uWKjmtkvomGULLjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUA 13 | A4IBAQCg/Po64hN09w4QxwLvFRo050NBpvTi4JHrC/xQjFWl60UlQ+tCICtKDRRA 14 | MCpOt+PqJlivm8sDrSn86vqQKMJfQHGUDExNpcEWFG+QLUJ0aX5jFUj6+V+2hAbO 15 | g3QR9OvqeewuIfpHQJ8CTEbSamhc03LC2eX0AqdQUwSMuNrNgrZ0BBVTMkEfx8fM 16 | vfhWPjbO7WDjj0NJrh/FRXxIplvog1vGVY5RNRNtGgs3hGwh+roNq0kxOTO+Ye5D 17 | rtFSQ9CfjZI9qsT+XA8R6WzvFqSZSuxQpPkh70Pl6TPlK/W4Pqec2izZSlJxKFp1 18 | /rHU0nyXHJ2d7X5iV/sd3/WTs8kV 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /tests/integration/molecule/misc_api_cert/files/sensu-api.cnf: -------------------------------------------------------------------------------- 1 | [server] 2 | basicConstraints=CA:FALSE 3 | subjectKeyIdentifier=hash 4 | authorityKeyIdentifier=issuer 5 | 6 | extendedKeyUsage=serverAuth 7 | keyUsage=digitalSignature, keyEncipherment 8 | subjectAltName=IP:127.0.0.1 9 | 10 | -------------------------------------------------------------------------------- /tests/integration/molecule/misc_api_cert/files/sensu-api.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDWjCCAkKgAwIBAgIUBvuM6lXj9IVDxOUs7Szg6+vzEu8wDQYJKoZIhvcNAQEL 3 | BQAwGDEWMBQGA1UEAwwNU2Vuc3UtdGVzdCBDQTAeFw0yMjEyMTIwNzE1MzRaFw0y 4 | NTEyMTEwNzE1MzRaMBQxEjAQBgNVBAMMCXNlbnN1LWFwaTCCASIwDQYJKoZIhvcN 5 | AQEBBQADggEPADCCAQoCggEBAOHOCPfinziVMh0dJljYnnJ7/H6+Tj6fbf+I01U8 6 | hRQLhhKoA6n51uuThS6ncBiWhyC6t09i/SbXqvybdIVrn1Gcj/yyDpeTDxKs3GHY 7 | i7q3xeDkJ/qWwsBK7sGtN3F6T/qQUvnhMhG8DzsNH+G11G3PnOJD6CMwmsCzFqip 8 | GmagDFUOleHaMDaTZOiT6C8Bv+w08KakGuRoKtJUlIJCps9Za1ZnpcRKv5nY7Mxo 9 | K1/K1M9dDmznuh0nHkSVjBig5j3I3k4Fto4ApIN/eGHoyCc9uXHCHoB8K7xwGeNQ 10 | eNuxzYUmryemA51p/AjtIIXe7Hn9XxkTmWolCiv14Prp/ZUCAwEAAaOBnzCBnDAJ 11 | BgNVHRMEAjAAMB0GA1UdDgQWBBQ+DDirz38IyldwTg9p38Ti0wAytzA9BgNVHSME 12 | NjA0oRykGjAYMRYwFAYDVQQDDA1TZW5zdS10ZXN0IENBghQFKeZSHo8IQXf/rNMn 13 | UOof2tw26zATBgNVHSUEDDAKBggrBgEFBQcDATALBgNVHQ8EBAMCBaAwDwYDVR0R 14 | BAgwBocEfwAAATANBgkqhkiG9w0BAQsFAAOCAQEAkXWRt3m4IGp/6+/icT5PCZ3M 15 | S7FCzx6f+2BxxvGdFX0JI1HTjqO7cUHQ57lC/eRHyx15W6CxgDkUCZJ/tJot0Q+k 16 | ZZPHUsO6mG+d/DdMyRbfzOtH0xSrIFZTXdG9gSfEGG+r5IX+TBcZ3BOHtIgRYJsK 17 | p3elglhsSgChxZ6SlcSp52KK9gaFcBywLtIt13BpRm/F9JX2IKmX4yZIFwvMg5W9 18 | MmDdR1GSBDe/uS9yRhst3hVOxBBLX9J2P1xBf4TYgmIAPqLhSCKIdr0ciRwwnV0D 19 | dOk8q2eCVLqgu+Hl/NJWqLvI99eRtya20uVV458ZMjVa1ugw4kcpU7UmOEZajg== 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /tests/integration/molecule/misc_api_cert/files/sensu-api.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEowIBAAKCAQEA4c4I9+KfOJUyHR0mWNiecnv8fr5OPp9t/4jTVTyFFAuGEqgD 3 | qfnW65OFLqdwGJaHILq3T2L9Jteq/Jt0hWufUZyP/LIOl5MPEqzcYdiLurfF4OQn 4 | +pbCwEruwa03cXpP+pBS+eEyEbwPOw0f4bXUbc+c4kPoIzCawLMWqKkaZqAMVQ6V 5 | 4dowNpNk6JPoLwG/7DTwpqQa5Ggq0lSUgkKmz1lrVmelxEq/mdjszGgrX8rUz10O 6 | bOe6HSceRJWMGKDmPcjeTgW2jgCkg394YejIJz25ccIegHwrvHAZ41B427HNhSav 7 | J6YDnWn8CO0ghd7sef1fGROZaiUKK/Xg+un9lQIDAQABAoIBAQCEUbwnpoEvIx6O 8 | uPozrhyLceRwUQyA3eQTjhZpKGHDcU1LuXEMNf+fZH7y6+NgRTVCFKg+uP8nt9HW 9 | 3THWzU47AMfPiHfMkryOcQVjwQWAkRg/xPM4gQf2rvJiRCLtOIONjO1SyIgSpGU4 10 | cWRxW5/0CWkhnjF2DZFhwpBQnWd/IsiiCrqCrEgKm4yjgu63LVEkBRmSwzkms2qO 11 | aWOBnut/DJNkMdV3Zaxb+MYkaYmrus6viPGk3brbt70qkuFzJh4l/KSZcCWHofUW 12 | 3Rs1nrgNmrzaDEscULNZTE/4WSL32tyXyTo8ujIqVQCgMXbWc1QujV1AyHL1EZep 13 | KRSYpn6BAoGBAPkTc35qlOZSOBE/GeIddqFlNbNK0XaJhjH0lNc1L/aoxNLQCNqX 14 | cUCu1CB2YVoERhghvuLUOULkeVt9LeJywpLYW7l3lLbqJoBWedRqEHAkVxGxARqO 15 | KWwgMyFgphTrkgfmSlOYWrZ1hW8BPL84pwQbLgyRU6jzkmHi0Re/GbjZAoGBAOgU 16 | +YgO47vqCfQhrinWYESsqH3OZGoAaIlRqEMv4vPIq3UHtWne1je9vGRCTCgdA+GJ 17 | 6tkIbx04m61FvPXW/HlWlSYvA4zafWZFKjWkNtsrOZBIknqtQ9h5ca1CsQjEfWLJ 18 | WdMN5DMTNQeK6irNHFHXFJHejlig/dCOdwF7oFUdAoGAXsgbHBEc5mSFN3Lmu5fw 19 | q8wi2j5vZQdCTMJA3YA850Uj2QEXTW9xxmaBDHVf6GxV7BrzU8fknmLpF3qUOmbn 20 | ShARH4u0yMJjslS1+bH+3V3G0FGmFN/iPWYnbt0jdjSKlnz47cS9SE+CXlJ/Nlkt 21 | nS9mn5ux1UoS+zLf1ISBGkkCgYAZ3XyR9VbcMpE5bCeE8id4f+WnX8FBLxp3c2pV 22 | UpjwooS5XkqRqgwl2jeM1Pa34cP09vH9jjsT/qMbBJKys2sf+s5UmxjCMfeX1k2F 23 | /O9ALekUc4Ifuf+9uIs6zBv+5iczQ02HgBzWtGVMmebPLlzhoh7gwvUKW6bt/3Kz 24 | 75tG4QKBgFz2h/AVPz52Fraztx7QUc2J9sgM4yERvZqVnVCYVINrczi7iV+LS+yE 25 | x4CenPWPRgnoh4P2jmqybmw+3rGsk4UyTPYZhvM7FUUI5DsD/Quk9KYgDIQBQTxV 26 | 0ryPzC6j8uYweF9xLKwfv+fIj8j+iqcOwhXWd5+E2YOXOIdKS3Oa 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /tests/integration/molecule/misc_api_cert/files/sensu-api.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDWjCCAkKgAwIBAgIUAOVga11hbTPIxN+jFbDcB6YX/PwwDQYJKoZIhvcNAQEL 3 | BQAwGDEWMBQGA1UEAwwNU2Vuc3UtdGVzdCBDQTAeFw0yMjEyMDkxMzM5NThaFw0y 4 | NTEyMDgxMzM5NThaMBQxEjAQBgNVBAMMCXNlbnN1LWFwaTCCASIwDQYJKoZIhvcN 5 | AQEBBQADggEPADCCAQoCggEBAJGoCboPEiiKj9E9YUUdVR3oIS1mHYQLqqd0T0Y5 6 | BTp4XbeLdvv/oFF5nol5QUWUJm7PHa8CUY6LO9k+fW2VkhQcBnrrv0H1e23DgyWm 7 | J2pOjp54RYHciGErRnAkwpNt3Z6Q6oMnnK77hp5YiPsk3AvwgQaHFgOpI1L6Z2VI 8 | difGuckMUruwVKT0q+y2zHDvewzf55J+ykBKVYjVEi8Kx/gaAIe12VybAyg5P0QM 9 | ZUiKfcb7f/sae4KEZOWSXKfh8HaK/YXQN0JxwFujPt+MHxtUlzEyOakWgBjhP7nQ 10 | BB8FgQmyE+m9xuq2bHei/qzx1183Pwd+zPrVoAWY+Rlv9x8CAwEAAaOBnzCBnDAJ 11 | BgNVHRMEAjAAMB0GA1UdDgQWBBTqiIfWrKiwVZTFchGktuW8WWtFRDA9BgNVHSME 12 | NjA0oRykGjAYMRYwFAYDVQQDDA1TZW5zdS10ZXN0IENBghQxv8cd6BODLyXX7rdB 13 | udWKli0pBjATBgNVHSUEDDAKBggrBgEFBQcDATALBgNVHQ8EBAMCBaAwDwYDVR0R 14 | BAgwBocEfwAAATANBgkqhkiG9w0BAQsFAAOCAQEANptW8pIOrmulcqZ78n+b95zu 15 | zcxoD0n1QjhouiEqlCgEaVoOpWbm12tds6pALDVuBNF1lYuTe2Kdffxoz/q7lpxb 16 | Z07fU5lXF3mGa8CtsbXxlnpRxu1HIQwChp3EGxjxhOiGmfxfULicOl/z3nfWR9zu 17 | +/7jpKRXAJ+O5JvxdU754cmXXftk+XncUz19ZbizX7trWDuqzkyTxD/0lNRA6OZN 18 | hVF8FVE/Mju3FXbY4atvptV4e8MOsz1vfS6piPtU9HzD2miWuoY4di+OgC3DDTQs 19 | 4eDkOLvyoJ04JQMst928Oka6NPHnfUVxBeQg9JtzCDbFT/km4bQ4snybQ4vPnQ== 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /tests/integration/molecule/misc_api_cert/molecule.yml: -------------------------------------------------------------------------------- 1 | scenario: 2 | test_sequence: 3 | - destroy 4 | - create 5 | - prepare 6 | - converge 7 | - destroy 8 | 9 | platforms: 10 | - name: backend 11 | image: quay.io/xlab-steampunk/sensu-go-tests-centos:7 12 | pre_build_image: true 13 | pull: true 14 | override_command: false 15 | privileged: true 16 | volumes: 17 | - /sys/fs/cgroup:/sys/fs/cgroup:rw 18 | cgroupns_mode: host 19 | etc_hosts: 20 | # sensu-api is the hostname used in the test certificate 21 | sensu-api: 127.0.0.1 22 | -------------------------------------------------------------------------------- /tests/integration/molecule/misc_api_cert/prepare.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Prepare 3 | hosts: all 4 | 5 | tasks: 6 | - name: Install backend with secured API 7 | include_role: 8 | name: sensu.sensu_go.backend 9 | vars: 10 | version: 5.21.0 11 | api_cert_file: files/sensu-api.crt 12 | api_key_file: files/sensu-api.key 13 | api_trusted_ca_file: files/sensu-api-ca.crt 14 | -------------------------------------------------------------------------------- /tests/integration/molecule/module_ad_auth_provider/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_ad_auth_provider/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_asset/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_asset/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_check/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_check/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_cluster/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_cluster/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_cluster_role/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_cluster_role/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_cluster_role_binding/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_cluster_role_binding/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_datastore/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_datastore/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_entity/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_entity/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_etcd_replicator/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_etcd_replicator/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_event/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_event/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_filter/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_filter/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_handler_set/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_handler_set/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_hook/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_hook/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_ldap_auth_provider/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_ldap_auth_provider/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_mutator/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_mutator/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_namespace/converge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | collections: 4 | - sensu.sensu_go 5 | hosts: all 6 | gather_facts: false 7 | tasks: 8 | - name: Fetch all namespaces 9 | namespace_info: 10 | auth: 11 | url: http://localhost:8080 12 | register: default_state 13 | 14 | - name: store starting length 15 | set_fact: 16 | starting_length: "{{ default_state.objects | length }}" 17 | 18 | - name: Create namespace 19 | namespace: 20 | auth: 21 | url: http://localhost:8080 22 | name: dev 23 | register: result 24 | 25 | - assert: 26 | that: 27 | - result is changed 28 | - result.object.name == 'dev' 29 | 30 | - name: Create namespace idempotence 31 | namespace: 32 | auth: 33 | url: http://localhost:8080 34 | name: dev 35 | register: result 36 | 37 | - assert: 38 | that: 39 | - result is not changed 40 | 41 | - name: Create a second namespace 42 | namespace: 43 | auth: 44 | url: http://localhost:8080 45 | name: production 46 | 47 | - name: Fetch all namespaces 48 | namespace_info: 49 | auth: 50 | url: http://localhost:8080 51 | register: result 52 | 53 | - assert: 54 | that: 55 | - result.objects | length == expected_length | int 56 | - result.objects.1.name == 'dev' 57 | vars: 58 | expected_length: "{{ starting_length | int + 2 }}" 59 | 60 | - name: Delete namespace 61 | namespace: 62 | auth: 63 | url: http://localhost:8080 64 | name: dev 65 | state: absent 66 | 67 | - name: Fetch all namespaces 68 | namespace_info: 69 | auth: 70 | url: http://localhost:8080 71 | register: result 72 | 73 | - assert: 74 | that: 75 | - result.objects | length == expected_length | int 76 | - result.objects.1.name == 'production' 77 | vars: 78 | expected_length: "{{ starting_length | int + 1 }}" 79 | -------------------------------------------------------------------------------- /tests/integration/molecule/module_namespace/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_namespace/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_oidc_auth_provider/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_oidc_auth_provider/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_pipe_handler/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_pipe_handler/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_pipeline/molecule.yml: -------------------------------------------------------------------------------- 1 | platforms: 2 | - name: v6.10.0 3 | image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.10.0 4 | pre_build_image: true 5 | pull: true 6 | override_command: false 7 | - name: v6.9.0 8 | image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.9.0 9 | pre_build_image: true 10 | pull: true 11 | override_command: false 12 | - name: v6.8.2 13 | image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.8.2 14 | pre_build_image: true 15 | pull: true 16 | override_command: false 17 | - name: v6.7.5 18 | image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.7.5 19 | pre_build_image: true 20 | pull: true 21 | override_command: false 22 | - name: v6.6.2 23 | image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.6.2 24 | pre_build_image: true 25 | pull: true 26 | override_command: false 27 | - name: v6.5.5 28 | image: quay.io/xlab-steampunk/sensu-go-tests-sensu:6.5.5 29 | pre_build_image: true 30 | pull: true 31 | override_command: false 32 | -------------------------------------------------------------------------------- /tests/integration/molecule/module_role/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_role/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_role_binding/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_role_binding/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_secret/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_secret/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_secrets_provider_env/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_secrets_provider_env/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_secrets_provider_vault/files/ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDCDCCAfCgAwIBAgITMgYuhrafZc78Bk5PXip8xwQqTjANBgkqhkiG9w0BAQsF 3 | ADAUMRIwEAYDVQQDDAlsb2NhbGhvc3QwHhcNMjAxMDA3MDYzMzQzWhcNNDAwMTI2 4 | MDYzMzQzWjAUMRIwEAYDVQQDDAlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEBAQUA 5 | A4IBDwAwggEKAoIBAQCk8LHitgJipeUaqWW2dsMe44TiT6XO17pPNJwRLFA7eSEN 6 | Vn5gCNd2yfEjsx7lXaZApghwz0YIE6gzkvFPS5cHCbPuBqyI6rSUPEXvMdkt7EGG 7 | 40uhcX/otp0FvQr+Uvqo9NQyavTrgEPTudUptLFJd8QkZaVzprx061K2uV8Kjc4h 8 | 0MDIX5+4amb+h4eEBloTjH4lc6INe2uezAodiRjUp/TOYJzr5OIPYd3jjbbB1G3T 9 | kwsQEz9qiEEwHN8AUGEFWqIy2O3BNTbS4D5Fv4n3U+HSFQdB5ORHGKbu/s0e8Tr8 10 | K5udPjM+ld8PazD2UIBBpWDbAqYvUrdTxYhxFqIrAgMBAAGjUzBRMB0GA1UdDgQW 11 | BBS6M9F187X6KhlndKvdTNxC25xRrzAfBgNVHSMEGDAWgBS6M9F187X6KhlndKvd 12 | TNxC25xRrzAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQAZvMa4 13 | R+AqR3lR3zpzFtN6OK/oFbUTloOE6+sWkFlE197YlvaUK0NmD67Xlvuor++KfCci 14 | ru2nOhUkqYRHQ5a/ZACEOhv0PyCcTTAsEWcjs/I/zBTxvzJUjX7o6X1wtVmo5lI5 15 | lLpru+5h5XsqHMnIbdqfGKJup3j44d0qUDUrVKAsS8ioWvmuyZyxczeKvb+CvQLq 16 | sNPSD+7H8l6WdWfo0unmCz7FkZDtSg9LCjzMF0TEe5D9ApWb6GtLy1XRKzg8jGzG 17 | MuuzNzlaqBgWI88HRL25ZkVLwNahb7dkkt82d8ghdmtkisXHm24BHwPnXOpQ2LGn 18 | ZPUwbq0OkVDt9nkr 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /tests/integration/molecule/module_secrets_provider_vault/files/client.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDazCCAlOgAwIBAgIUbhKhIYBliY9SvDegW9ND5+YAQSowDQYJKoZIhvcNAQEL 3 | BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM 4 | GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMDEwMDYwOTMwMjZaFw0zMDEw 5 | MDQwOTMwMjZaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw 6 | HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggEiMA0GCSqGSIb3DQEB 7 | AQUAA4IBDwAwggEKAoIBAQDApjHtQI+w5Lu2uoMMo+iAcVb+6PjzWVL1G34d31HK 8 | hZynEPbCkJzpXsUOnbPagWmTXFMBblqgE1Pj4zT97oqWPBlIV3UA5M7rBQel76Vq 9 | YPKNDcZ8fGtCaL3wFFmN3ou6QaI+Zy3CJAy6Q71426xRawHWCgF7in3k90bVw3Qy 10 | hrW8VrEgcwobdHn79W9idx+OBYcku5Fn1ciZn9RQoL0GRIRsg5IyB0Uy9W1Vyc74 11 | Bp2LTySn4QwPflfCjb9+83oeMTwPTDU3RHPVbMVoL87+jXD5TeZTCNooIYDRYjP6 12 | 3gWEQMVL+LJpaFZvdp26uArJnCu69wgyvpzGqnExKgl3AgMBAAGjUzBRMB0GA1Ud 13 | DgQWBBRBlAIaZUvLzoGXdIfOXulVTGIg0zAfBgNVHSMEGDAWgBRBlAIaZUvLzoGX 14 | dIfOXulVTGIg0zAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBG 15 | U/Xnzm5+H6gXzq8hvFBIeaMYQmTgLwKt0w7yHBSQSNJC4qouIPgbyKKwrQJOvdI3 16 | /q3GRTkzMB/GKHRwh9nE4Z9wBLLY8b5K2t2yyQjpNtHyKeO+cc3E1gKSa0/QMEHh 17 | OLtQsCixfACb3U0KizhwocACQ52NVMd2LhBuO4UCAGi1I5SFZzrgIcrG9WoB1Qzx 18 | YoWh/49BL45LuLQ9MvPxya6ZuE0Pg38xRr+5yaEbnEAinVGy5eL+PNa5aMPogUB3 19 | +hINK/Ous3ab0zJyJ+1lN/9ijx43R2RfCo8GXA7x9Wz+N+nW8MAJbICiJR8pljiy 20 | GFQiUdAX24flMYN14ZjX 21 | -----END CERTIFICATE----- 22 | -------------------------------------------------------------------------------- /tests/integration/molecule/module_secrets_provider_vault/files/client.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDApjHtQI+w5Lu2 3 | uoMMo+iAcVb+6PjzWVL1G34d31HKhZynEPbCkJzpXsUOnbPagWmTXFMBblqgE1Pj 4 | 4zT97oqWPBlIV3UA5M7rBQel76VqYPKNDcZ8fGtCaL3wFFmN3ou6QaI+Zy3CJAy6 5 | Q71426xRawHWCgF7in3k90bVw3QyhrW8VrEgcwobdHn79W9idx+OBYcku5Fn1ciZ 6 | n9RQoL0GRIRsg5IyB0Uy9W1Vyc74Bp2LTySn4QwPflfCjb9+83oeMTwPTDU3RHPV 7 | bMVoL87+jXD5TeZTCNooIYDRYjP63gWEQMVL+LJpaFZvdp26uArJnCu69wgyvpzG 8 | qnExKgl3AgMBAAECggEAeP9pWEQ2e7oOFESszqGcBCArrcsRoXY23m+4FHcQ3gxx 9 | SZUkByvhAcpeJkHyloi1kLJqB/oRvXymMfmgbOUH8jgpAQC9IiSTuZTdKuGLmXbu 10 | oJ1ITyOuEnXK5iFB5hMi24chqeQQH2GZBNxLAr+mSTTWYGLEb52aWNbejKBIOPq9 11 | xnHD3gkFwod5dQt9ZY0bh+jTdM6cRuVyUooxbkFIkblHDQ8vEWsdC+b4rAXVH71e 12 | JjrnI4y/4zDdF5akexpaHrva+J1Y2PCkdFvfO4drl5XKysSiUMX37XN32LxU5/ON 13 | c6umKQnot1GL4ognOQw5HcygkT2Y8ltVbdcEK21xYQKBgQD7e1J48DYvpOhVVMaY 14 | fqV2RuXKpoyy+7RIU+YrxaduwJYqH6ZWnLOYf2ZtlKRVsuHw+4fjAxw4DW6FzkMA 15 | hXcgFwbLQO97dcxETPcq7Hny7mSQy8PO8iLXMHqOerxo16DNivc6Kw5NV+S/5XaU 16 | IMNCmNl+1ZzkdNhUjeknV5Sf/wKBgQDEHEaKXAQoxGffRFoZK0aj3FX8N+qsYn4c 17 | mftCkWZzKLMvwgjt0CXsHqrx9C3WecF2yrTGyMEsuI6eOBWVLqfkTUH9JgcjeFiF 18 | R2c25zBS28WZtZwFaIi3oUtXHX2rKyWza3rQZSqEgXXV+ck/Ks7LFqpuHmttnYHt 19 | qTXNIx+WiQKBgBpsXMAETU04QIkmvS8sr2n8DQz77vCnbcvjtN2IiQ0kAyMt7CZR 20 | lLVDPZnp8lJm10KgyyhZHU/uaVx5zaRyYY/nm3kju4X3XJ0YkSfbbPzPe5WTM2G9 21 | I1gE6fuqfb1uWqD+JvffqkMKJyjajVkHED0hHkkrXK7McCaCOqs9koo1AoGBAIEN 22 | NmJgUSBetxgWi8/aSZ8VJMRYK6cLHYBG2DCjLC8GDnyUDHoqqnnqaIXWML/d2bEJ 23 | jdLuUyjRvpBhydolHLjBGnazKqltzZrPNR3NH2C3XR5cg3KPqsBkdQa70nHsb9/V 24 | D7nJiSQvaVLJEGTwD6tXnAnhHMLCjrjNzCjVPzk5AoGBANHxGdKUaZivQV3dMo3p 25 | 6WHfwe1rTdaiahvEHH2wi4ch+m7b92p+ey2aPg8kvnHKh8TG0NuAcJZ1/lG2qex8 26 | 89pmdwaqkggi/ApPR0vvZiIQgSawlPW3pg1VAW/DtzYGAJlGWwbI212szN94MDYH 27 | t31cQ5V1qUo1rJaQE0rM0OwB 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /tests/integration/molecule/module_secrets_provider_vault/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_secrets_provider_vault/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_silence/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_silence/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_socket_handler/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_socket_handler/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_tessen/converge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | collections: 4 | - sensu.sensu_go 5 | hosts: all 6 | gather_facts: false 7 | tasks: 8 | - name: Call tessen with missing required parameters 9 | tessen: 10 | auth: 11 | url: http://localhost:8080 12 | ignore_errors: true 13 | register: result 14 | 15 | - assert: 16 | that: 17 | - result is failed 18 | - "result.msg == 'missing required arguments: state'" 19 | 20 | - name: Disable tessen # Tessen is enabled by default on Sensu backends 21 | tessen: 22 | auth: 23 | url: http://localhost:8080 24 | state: disabled 25 | register: result 26 | 27 | - assert: 28 | that: 29 | - result is changed 30 | - result.object.opt_out == True 31 | 32 | - name: Enable tessen 33 | tessen: 34 | auth: 35 | url: http://localhost:8080 36 | state: enabled 37 | register: result 38 | 39 | - assert: 40 | that: 41 | - result is changed 42 | - result.object.opt_out == False 43 | 44 | - name: Try to enable already enabled tessen 45 | tessen: 46 | auth: 47 | url: http://localhost:8080 48 | state: enabled 49 | register: result 50 | 51 | - assert: 52 | that: 53 | - result is not changed 54 | -------------------------------------------------------------------------------- /tests/integration/molecule/module_tessen/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_tessen/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/module_user/molecule.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensu/sensu-go-ansible/1a7072a36685fd9dca4d2dd2074610cf112c9199/tests/integration/molecule/module_user/molecule.yml -------------------------------------------------------------------------------- /tests/integration/molecule/role_agent_config/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | scenario: 3 | test_sequence: 4 | - destroy 5 | - create 6 | - prepare 7 | - converge 8 | - destroy 9 | 10 | platforms: 11 | - name: centos 12 | image: quay.io/xlab-steampunk/sensu-go-tests-centos:7 13 | pre_build_image: true 14 | pull: true 15 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_agent_config/prepare.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Prepare 3 | hosts: all 4 | 5 | tasks: 6 | - name: Create sensu group 7 | group: 8 | name: sensu 9 | 10 | - name: Create sensu user 11 | # We need FQCN here because we are running test from within the 12 | # collection. In this case, our collection becomes the default 13 | # collection and so the sensu.sensu_go.user module shadows the builtin 14 | # one. 15 | ansible.builtin.user: 16 | name: sensu 17 | groups: sensu 18 | 19 | - name: Create /etc/sensu folder 20 | file: 21 | state: directory 22 | path: /etc/sensu 23 | owner: sensu 24 | group: sensu 25 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_agent_default/converge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: agents 4 | roles: 5 | - sensu.sensu_go.agent 6 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_agent_default/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | scenario: 3 | test_sequence: 4 | - destroy 5 | - create 6 | - converge 7 | - verify 8 | - check 9 | - destroy 10 | 11 | platforms: 12 | - name: centos 13 | image: quay.io/xlab-steampunk/sensu-go-tests-centos:7 14 | pre_build_image: true 15 | pull: true 16 | groups: [agents] 17 | override_command: false 18 | privileged: true 19 | volumes: 20 | - /sys/fs/cgroup:/sys/fs/cgroup:rw 21 | cgroupns_mode: host 22 | 23 | # Upstream container - just to populate the inventory 24 | provisioner: 25 | inventory: 26 | hosts: 27 | all: 28 | children: 29 | backends: 30 | hosts: 31 | upstream-backend: 32 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_agent_default/verify.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Verify 3 | hosts: agents 4 | 5 | tasks: 6 | - name: Agent configuration must exist 7 | stat: 8 | path: /etc/sensu/agent.yml 9 | register: result 10 | 11 | - assert: 12 | that: 13 | - result.stat.exists 14 | - result.stat.mode == '0600' 15 | - result.stat.pw_name == 'sensu' 16 | - result.stat.gr_name == 'sensu' 17 | 18 | - name: Confirm default configuration settings 19 | slurp: 20 | src: /etc/sensu/agent.yml 21 | register: agent_yml 22 | 23 | - assert: 24 | that: 25 | - | 26 | agent_yml.content | b64decode | from_yaml == { 27 | "backend-url": ["ws://upstream-backend:8081"], 28 | } 29 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_agent_secured/converge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Pre-converge secure backend config step 3 | hosts: backends 4 | gather_facts: false 5 | tasks: 6 | - name: Set dummy backend PKI variables 7 | set_fact: 8 | api_key_file: /tmp/dummy.key 9 | 10 | - debug: 11 | msg: "{{ hostvars['upstream-backend']['api_key_file'] }}" 12 | 13 | - name: Converge 14 | hosts: agents 15 | vars: 16 | agent_trusted_ca_file: files/sensu-agent-trusted-ca.crt 17 | roles: 18 | - sensu.sensu_go.agent 19 | 20 | - name: Verify configure_agent 21 | hosts: agents 22 | tasks: 23 | - name: The trusted CA store file must exist 24 | stat: 25 | path: /etc/sensu/sensu-agent-trusted-ca.crt 26 | register: result 27 | 28 | - assert: 29 | that: 30 | - "{{ result.stat.exists }}" 31 | - "{{ result.stat.pw_name == 'sensu' }}" 32 | - "{{ result.stat.gr_name == 'sensu' }}" 33 | - "{{ result.stat.mode == '0644' }}" 34 | 35 | - name: Confirm secured agent configuration settings 36 | lineinfile: 37 | path: &agent_yml /etc/sensu/agent.yml 38 | line: '{{ item }}' 39 | with_items: 40 | - 'backend-url:' 41 | - '- wss://upstream-backend:8081' 42 | - 'trusted-ca-file: /etc/sensu/sensu-agent-trusted-ca.crt' 43 | - 'insecure-skip-tls-verify: false' 44 | register: result 45 | 46 | - assert: 47 | that: 48 | - result is not changed 49 | 50 | - name: Default configuration 51 | hosts: agents 52 | gather_facts: false 53 | roles: 54 | - sensu.sensu_go.agent 55 | 56 | - name: Verify default configuration 57 | hosts: agents 58 | tasks: 59 | - name: Confirm that none of secured configuration settings leak in 60 | lineinfile: 61 | path: *agent_yml 62 | regexp: '{{ item }}' 63 | state: absent 64 | with_items: 65 | - '^trusted-ca-file:' 66 | - '^insecure-skip-tls-verify:' 67 | register: result 68 | 69 | - assert: 70 | that: 71 | - result is not changed 72 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_agent_secured/files/sensu-agent-trusted-ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDUTCCAjmgAwIBAgIULehsb6UOfWOosQs9hh0u0GJfIUcwDQYJKoZIhvcNAQEL 3 | BQAwGDEWMBQGA1UEAwwNU2Vuc3UtdGVzdCBDQTAeFw0xOTExMDYxNzIyMzlaFw0y 4 | OTExMDMxNzIyMzlaMBgxFjAUBgNVBAMMDVNlbnN1LXRlc3QgQ0EwggEiMA0GCSqG 5 | SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDXGeaaBh1Ysfd+YWbOHrlb9fIb39wp/Xj3 6 | 8JvvdcTvEu9IvDrFASUYuyDo/y8s1XGMulzjKO1BzJr7NUTcMfvxMrXlKQFxmPWS 7 | KxNVlPerBgiY8013ETtx1v91rq6K2tX2s1GnQOJ2+MWBHLpLRqa69l2XtIxR33+u 8 | 53T/vJAZVxzXU7pSfbRA7EvvaUry4IdCVhf8GCgvYopfZrxzByJg0fVgLNfbAlXb 9 | 7bBFnpbVabseAaL+jKeikejK1wy2DgcNvfTxZRc8V5MohyQKepgbIYegrmFx9gKg 10 | vRtn/neGBFv3KndlogNZrYkH6qJk9Qkgjm4ZxgylGgnKiT/9Bn07AgMBAAGjgZIw 11 | gY8wHQYDVR0OBBYEFGVvNX0RCwv9O8/mO5X6NWuADSfpMFMGA1UdIwRMMEqAFGVv 12 | NX0RCwv9O8/mO5X6NWuADSfpoRykGjAYMRYwFAYDVQQDDA1TZW5zdS10ZXN0IENB 13 | ghQt6GxvpQ59Y6ixCz2GHS7QYl8hRzAMBgNVHRMEBTADAQH/MAsGA1UdDwQEAwIB 14 | BjANBgkqhkiG9w0BAQsFAAOCAQEAP01K867avDUQpSsdhKONcZ/QHpL7ao/cO+in 15 | NbjQ9BEvV0Zjiw+xhlNy2U3G1UhbwOgCTIs6QLSA9sQyl3uAgXua9VmVH2bHT84m 16 | tRS6K0olAw5xAMwCH6Nf6wTBABDk4O4ny1XYFRpMYsSrvk1S1LBGSwLuDVHIb+3K 17 | 3yOxCIROFsPy00+CimqXS3GwpFBerXXCAH7Rq8dyCMC1anXMX8YJz5WrpKW9wCrQ 18 | RtnuWLImCu5w9Oe0QtKKZmh3wJD6uBo7gxX8ZugtrpZcZMUpo6DS1KsiKOTnibCJ 19 | 6k+A09PhNoorVrNnw/xmWgLf0J3CBE2jxUlq57QPYcVnFSs39w== 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_agent_secured/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platforms: 3 | - name: centos 4 | image: quay.io/xlab-steampunk/sensu-go-tests-centos:7 5 | pre_build_image: true 6 | pull: true 7 | groups: [agents] 8 | override_command: false 9 | privileged: true 10 | volumes: 11 | - /sys/fs/cgroup:/sys/fs/cgroup:rw 12 | cgroupns_mode: host 13 | 14 | # Upstream container - just to populate the inventory 15 | provisioner: 16 | inventory: 17 | hosts: 18 | all: 19 | children: 20 | backends: 21 | hosts: 22 | upstream-backend: 23 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_backend_config/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | scenario: 3 | test_sequence: 4 | - destroy 5 | - create 6 | - prepare 7 | - converge 8 | - destroy 9 | 10 | platforms: 11 | - name: centos 12 | image: quay.io/xlab-steampunk/sensu-go-tests-centos:7 13 | pre_build_image: true 14 | pull: true 15 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_backend_config/prepare.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Prepare 3 | hosts: all 4 | 5 | tasks: 6 | - name: Create sensu group 7 | group: 8 | name: sensu 9 | 10 | - name: Create sensu user 11 | # We need FQCN here because we are running test from within the 12 | # collection. In this case, our collection becomes the default 13 | # collection and so the sensu.sensu_go.user module shadows the builtin 14 | # one. 15 | ansible.builtin.user: 16 | name: sensu 17 | groups: sensu 18 | 19 | - name: Create /etc/sensu folder 20 | file: 21 | state: directory 22 | path: /etc/sensu 23 | owner: sensu 24 | group: sensu 25 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_backend_default/converge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: all 4 | 5 | tasks: 6 | - name: Install backend 7 | include_role: 8 | name: sensu.sensu_go.backend 9 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_backend_default/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | scenario: 3 | test_sequence: 4 | - destroy 5 | - create 6 | - converge 7 | - idempotence 8 | - verify 9 | - check 10 | - destroy 11 | 12 | platforms: 13 | - name: centos 14 | image: quay.io/xlab-steampunk/sensu-go-tests-centos:7 15 | pre_build_image: true 16 | pull: true 17 | override_command: false 18 | privileged: true 19 | volumes: 20 | - /sys/fs/cgroup:/sys/fs/cgroup:rw 21 | cgroupns_mode: host 22 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_backend_default/verify.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Verify 3 | hosts: all 4 | 5 | tasks: 6 | - name: Backend configuration must exist 7 | stat: 8 | path: /etc/sensu/backend.yml 9 | register: result 10 | 11 | - assert: 12 | that: 13 | - result.stat.exists 14 | - result.stat.mode == '0600' 15 | - result.stat.pw_name == 'sensu' 16 | - result.stat.gr_name == 'sensu' 17 | 18 | - name: Confirm default configuration settings 19 | slurp: 20 | src: /etc/sensu/backend.yml 21 | register: backend_yml 22 | 23 | - assert: 24 | that: 25 | - | 26 | backend_yml.content | b64decode | from_yaml == { 27 | "state-dir": "/var/lib/sensu/sensu-backend", 28 | } 29 | 30 | - name: Make sure login works 31 | uri: 32 | url: http://localhost:8080/auth 33 | url_username: admin 34 | url_password: P@ssw0rd! 35 | force_basic_auth: true 36 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_backend_secured/files/client-ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDUTCCAjmgAwIBAgIULehsb6UOfWOosQs9hh0u0GJfIUcwDQYJKoZIhvcNAQEL 3 | BQAwGDEWMBQGA1UEAwwNU2Vuc3UtdGVzdCBDQTAeFw0xOTExMDYxNzIyMzlaFw0y 4 | OTExMDMxNzIyMzlaMBgxFjAUBgNVBAMMDVNlbnN1LXRlc3QgQ0EwggEiMA0GCSqG 5 | SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDXGeaaBh1Ysfd+YWbOHrlb9fIb39wp/Xj3 6 | 8JvvdcTvEu9IvDrFASUYuyDo/y8s1XGMulzjKO1BzJr7NUTcMfvxMrXlKQFxmPWS 7 | KxNVlPerBgiY8013ETtx1v91rq6K2tX2s1GnQOJ2+MWBHLpLRqa69l2XtIxR33+u 8 | 53T/vJAZVxzXU7pSfbRA7EvvaUry4IdCVhf8GCgvYopfZrxzByJg0fVgLNfbAlXb 9 | 7bBFnpbVabseAaL+jKeikejK1wy2DgcNvfTxZRc8V5MohyQKepgbIYegrmFx9gKg 10 | vRtn/neGBFv3KndlogNZrYkH6qJk9Qkgjm4ZxgylGgnKiT/9Bn07AgMBAAGjgZIw 11 | gY8wHQYDVR0OBBYEFGVvNX0RCwv9O8/mO5X6NWuADSfpMFMGA1UdIwRMMEqAFGVv 12 | NX0RCwv9O8/mO5X6NWuADSfpoRykGjAYMRYwFAYDVQQDDA1TZW5zdS10ZXN0IENB 13 | ghQt6GxvpQ59Y6ixCz2GHS7QYl8hRzAMBgNVHRMEBTADAQH/MAsGA1UdDwQEAwIB 14 | BjANBgkqhkiG9w0BAQsFAAOCAQEAP01K867avDUQpSsdhKONcZ/QHpL7ao/cO+in 15 | NbjQ9BEvV0Zjiw+xhlNy2U3G1UhbwOgCTIs6QLSA9sQyl3uAgXua9VmVH2bHT84m 16 | tRS6K0olAw5xAMwCH6Nf6wTBABDk4O4ny1XYFRpMYsSrvk1S1LBGSwLuDVHIb+3K 17 | 3yOxCIROFsPy00+CimqXS3GwpFBerXXCAH7Rq8dyCMC1anXMX8YJz5WrpKW9wCrQ 18 | RtnuWLImCu5w9Oe0QtKKZmh3wJD6uBo7gxX8ZugtrpZcZMUpo6DS1KsiKOTnibCJ 19 | 6k+A09PhNoorVrNnw/xmWgLf0J3CBE2jxUlq57QPYcVnFSs39w== 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_backend_secured/files/etcd-client.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDTrL6kRSLtjwuy 3 | GQ2rYNsLxPuKcyKa+FQWoEwSAKEh7wPKgymOkBKHA3gSDk+5HPCiVwZR/pxq70Wa 4 | a9Uy31hE6pvtTeEZ387t6pCksS5VomyHUxM43tvM9sxJuoWqKT0OyWrAuIUWpzQa 5 | KtnM9A4eaDVtSt1dQ/Zw2gonXnfujNlG+HAu4zyXfVXHxg3nIGHfnll4l2wNXO3T 6 | yNfY83x7WC8K+bOlY0G2auayvEjry0t2Ky4+nBrbyfEvGnxD2zhrm3/Q1yV8P1Ad 7 | cBEGqNYUtcTd6j0o2Ve3qtImAcxe8a5IKKFK7qztnH5h7zcSZ3vZBQuEUXW+BJaJ 8 | t9GV1sphAgMBAAECggEAX+J1bUYgH0pX+vIcXhB+ySMO6tVizJ5GwQUV0GXWl9+E 9 | cRzfG0QqEFzC7DLtbCYu3ura4xOZ2VrPxbapGeVQP8+imGlZ2XWnb+B8aw4Tthjg 10 | XqCEKZPSL1NwkMlcOQt7LBKTN/+d0fglwuC8TnoTVzTPVtW91rytistKJDFH1JfI 11 | AwOyMoWkNYP3zDdMJn9dWkOXsNjK2VoxzCh/DhOcI/2gO4v7fM1w8A8iGYi5uMD4 12 | b1IzIqcvdgeyGEXhzu2PcJ0Kr1dR2B2VGJJ4kUqIjUGxG7gSE8X0siEBmSBNBou9 13 | lFp35esx2ffEnzPZaxAdqOpW0eV/iWxxYKFKX37PAQKBgQDpBOxqgbaGqu20MBVB 14 | rQWh4CjalnvDbjyCyLfAb/6iI8MLnSvw9nfUS9X0TGnMmbZ5gk+7LDKczfs6NOHC 15 | qBs34tAHHebimYqNII5UFc6OyYHpZsLmCG7+JgJDDD299jyZsNHBuw46TUOwdj9T 16 | rRUdAX4s5fDzLmNzu/vN7PqXcQKBgQDojO8qscWy8GWbbxUpRjCetxNPpBf83rke 17 | SL8o283ziMNmhn2L1RHa5vAYBHU1n2aIbYJiU6UEoJnCCpjxcigZdEacE7wsx8Et 18 | alCzlitLuCW0C3bdvxERm1Ya9frhxq+ljE9Kjn8IQ9+1+4zE0Xzk9bnEQVQsySWk 19 | siJUay9J8QKBgQCu6iY5cPM9tZNHfgyGx0WCFM02AF4Y/mfn2Jmul6MxvNyNnEa+ 20 | 05RxxRdvEekdT4ldPsdw/iVj9W8Pa2DIiP4dfmGf5f9Ju+34MCcG0XPDVVnyhVPp 21 | 7wy6NHfgMpEqRmuJBuT9otd0Rkl4bdrtifBeXJ+FPnoXYYv/9W14T9pv0QKBgBpn 22 | Tgxp7Ml5VAAG578s8f5DSRUEy5hxbVFL7zBjbInXIGB2qrCCu6lACUig0PIKrCiX 23 | TnN9jcHtvidy7pSTYowpUI8OCpKHB57xcEJDrZzGRrmfh5p7xCNcoLUk8pxJ482H 24 | FcWgUjoNAsx1yDDcnDKe1725sSX4nKaLdyxgkxjxAoGAVzuCl7Kl2RjOCIWKG46N 25 | vIl0nCdyTlJb1ammNr2cxIkjreSjenYS+Y8aXJOVVVDux+QB2LiQioMBDN/KIQ0k 26 | 55enQr0iKrjNIa5GeGN8uNnsrUoJ/9YfRsEq3rokns7kvSdsNFGFH4UOwuuEd4Qb 27 | y6OFkERhzgGm4TcsRPeOPiM= 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_backend_secured/files/etcd-peer-ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDUTCCAjmgAwIBAgIULehsb6UOfWOosQs9hh0u0GJfIUcwDQYJKoZIhvcNAQEL 3 | BQAwGDEWMBQGA1UEAwwNU2Vuc3UtdGVzdCBDQTAeFw0xOTExMDYxNzIyMzlaFw0y 4 | OTExMDMxNzIyMzlaMBgxFjAUBgNVBAMMDVNlbnN1LXRlc3QgQ0EwggEiMA0GCSqG 5 | SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDXGeaaBh1Ysfd+YWbOHrlb9fIb39wp/Xj3 6 | 8JvvdcTvEu9IvDrFASUYuyDo/y8s1XGMulzjKO1BzJr7NUTcMfvxMrXlKQFxmPWS 7 | KxNVlPerBgiY8013ETtx1v91rq6K2tX2s1GnQOJ2+MWBHLpLRqa69l2XtIxR33+u 8 | 53T/vJAZVxzXU7pSfbRA7EvvaUry4IdCVhf8GCgvYopfZrxzByJg0fVgLNfbAlXb 9 | 7bBFnpbVabseAaL+jKeikejK1wy2DgcNvfTxZRc8V5MohyQKepgbIYegrmFx9gKg 10 | vRtn/neGBFv3KndlogNZrYkH6qJk9Qkgjm4ZxgylGgnKiT/9Bn07AgMBAAGjgZIw 11 | gY8wHQYDVR0OBBYEFGVvNX0RCwv9O8/mO5X6NWuADSfpMFMGA1UdIwRMMEqAFGVv 12 | NX0RCwv9O8/mO5X6NWuADSfpoRykGjAYMRYwFAYDVQQDDA1TZW5zdS10ZXN0IENB 13 | ghQt6GxvpQ59Y6ixCz2GHS7QYl8hRzAMBgNVHRMEBTADAQH/MAsGA1UdDwQEAwIB 14 | BjANBgkqhkiG9w0BAQsFAAOCAQEAP01K867avDUQpSsdhKONcZ/QHpL7ao/cO+in 15 | NbjQ9BEvV0Zjiw+xhlNy2U3G1UhbwOgCTIs6QLSA9sQyl3uAgXua9VmVH2bHT84m 16 | tRS6K0olAw5xAMwCH6Nf6wTBABDk4O4ny1XYFRpMYsSrvk1S1LBGSwLuDVHIb+3K 17 | 3yOxCIROFsPy00+CimqXS3GwpFBerXXCAH7Rq8dyCMC1anXMX8YJz5WrpKW9wCrQ 18 | RtnuWLImCu5w9Oe0QtKKZmh3wJD6uBo7gxX8ZugtrpZcZMUpo6DS1KsiKOTnibCJ 19 | 6k+A09PhNoorVrNnw/xmWgLf0J3CBE2jxUlq57QPYcVnFSs39w== 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_backend_secured/files/etcd-peer.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDdKjVHsm13DdWi 3 | FlAgl5Pp9sQBBLcqYgRSAWhcmPLlgvbrmnebygqfYTRN9LWu4L2KXXkDtBDD6vOM 4 | 4oh5/2gq3dXR1WiaYS0LSQOu/Bsmp4kf+3bigYFyvULCnmDZDS5ygcMRxs1jZFKp 5 | XdWFwTWwkyre00Ys5BDVfZLpPP/1tH7i/P1rnsGhoMlsMa3SQglVnt7uNwZAx2Ha 6 | yV7YQMs/H3uTEcPlXJ3l/Hdnkt7Dij6HFdxHrTQXhLSyIY6PL9g6kplMgNcGd108 7 | ZttTFe6lXxIpGQcwoXF71R/uJLOcAm62Qs0ZlnPjx8QgxaR1tLWFQ2jkkV89+u0O 8 | NPH+qQylAgMBAAECggEALk6aHUr0tIrHAksdt9VE+SXb4EK2fz9KnEkDKvAzW27S 9 | eH49MPdaxgg6RWBJcjZIOWJc5jOblwnouMTtwm2ByAfuryK55ikWn1hIVykeHjfR 10 | 9EpYmBB5pCaQheNXb9rcsMkOqPgxJPBqhl/JR1ou/auyvDkMZnXSOIE0c3V8OluO 11 | nL39RHNCz76bNZSpe6BbYH6Ch8xkhCuYrzlIuBTSduE1aOK/Zugf+AMlNbxekdYv 12 | 8rhlCkO4lX752Dy8Z6x6KqRwRrXk+yeAhL7BITpsMCtJCR7XIsXKr9u/465tkjhC 13 | DlkqFhwk2I9uG0ygtkUkYpfakx0FBoroAQc3qAgQuQKBgQD+6BPb9nvvS403DcEh 14 | KNV0Pegdjms4KGiZmhOskWPOmMVKyIUHULgcQiwoROPzSfHjHABRuaVUz2+n37Kx 15 | kU9h+FTolIQUD/S9aYwEIf83Eu7CGj9ictLUPeLxbGSJ6B5+74D8RuOj5jS2VNug 16 | kJeBl0OWgD7ZXJF3LotSmnyiuwKBgQDeHRPaaBqp+5rZOLghyztsXnXQEcvMl5pt 17 | wUnm77XMfDIJf+KDKdOA7avelcMsuv1UDQNpckshaeU6W5UYrw6CI/gpB5JHJBjQ 18 | Bs6kTEw73t0+B1C9X/MA/AHIbk4TYLluxrv8pCprAptACuvEyHX+d03lETw+slzD 19 | mLWDMnqIHwKBgQCDbifnL1TBkkPyke31afd9IvpOWwNfhj5AjJf+T0yV1mFLaM5m 20 | cjErqNbZwIOECqlkfyiO+tiLPRWGCio5sgGrMv6cmQ7sxTlcfFJMQzczL1jZzezG 21 | lwurkWk1L706+erXaigoa2iuNmERbfl79XGYyOR5chB1xGvgdqgxZCRFRwKBgDxz 22 | s4yVGvS6uwl2C39/Hdw/1VbdERfNB0Xp/qAxC8zs3H2DZfYG8z668TUyk51gA0TW 23 | CeCwL8yXUsFQXcMLGirHeWpJWkGsjGhKAgHrljARVyvjt9DjBXN2I1IW238gqzeA 24 | NXfsgnL/kZubnVHAsYShmfzHdRsnVmIR9Q0RNxJHAoGBAMfqM6egc5JRSmDhA408 25 | d/oKasqYuPfNKWjZNfmDJcs1yHjaCJdQMkLlAi7a9QTi05KfEJGFf/k+ai7OIInw 26 | TCgworaS8+y/1YihDIMGHfFF2B3IYEJQkEIDHXUBaVA9xMXgYLBDYAme82riZia2 27 | 9mDJn1VPU0HRotyDYwoC34JV 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_backend_secured/files/sensu-api-ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDUTCCAjmgAwIBAgIULehsb6UOfWOosQs9hh0u0GJfIUcwDQYJKoZIhvcNAQEL 3 | BQAwGDEWMBQGA1UEAwwNU2Vuc3UtdGVzdCBDQTAeFw0xOTExMDYxNzIyMzlaFw0y 4 | OTExMDMxNzIyMzlaMBgxFjAUBgNVBAMMDVNlbnN1LXRlc3QgQ0EwggEiMA0GCSqG 5 | SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDXGeaaBh1Ysfd+YWbOHrlb9fIb39wp/Xj3 6 | 8JvvdcTvEu9IvDrFASUYuyDo/y8s1XGMulzjKO1BzJr7NUTcMfvxMrXlKQFxmPWS 7 | KxNVlPerBgiY8013ETtx1v91rq6K2tX2s1GnQOJ2+MWBHLpLRqa69l2XtIxR33+u 8 | 53T/vJAZVxzXU7pSfbRA7EvvaUry4IdCVhf8GCgvYopfZrxzByJg0fVgLNfbAlXb 9 | 7bBFnpbVabseAaL+jKeikejK1wy2DgcNvfTxZRc8V5MohyQKepgbIYegrmFx9gKg 10 | vRtn/neGBFv3KndlogNZrYkH6qJk9Qkgjm4ZxgylGgnKiT/9Bn07AgMBAAGjgZIw 11 | gY8wHQYDVR0OBBYEFGVvNX0RCwv9O8/mO5X6NWuADSfpMFMGA1UdIwRMMEqAFGVv 12 | NX0RCwv9O8/mO5X6NWuADSfpoRykGjAYMRYwFAYDVQQDDA1TZW5zdS10ZXN0IENB 13 | ghQt6GxvpQ59Y6ixCz2GHS7QYl8hRzAMBgNVHRMEBTADAQH/MAsGA1UdDwQEAwIB 14 | BjANBgkqhkiG9w0BAQsFAAOCAQEAP01K867avDUQpSsdhKONcZ/QHpL7ao/cO+in 15 | NbjQ9BEvV0Zjiw+xhlNy2U3G1UhbwOgCTIs6QLSA9sQyl3uAgXua9VmVH2bHT84m 16 | tRS6K0olAw5xAMwCH6Nf6wTBABDk4O4ny1XYFRpMYsSrvk1S1LBGSwLuDVHIb+3K 17 | 3yOxCIROFsPy00+CimqXS3GwpFBerXXCAH7Rq8dyCMC1anXMX8YJz5WrpKW9wCrQ 18 | RtnuWLImCu5w9Oe0QtKKZmh3wJD6uBo7gxX8ZugtrpZcZMUpo6DS1KsiKOTnibCJ 19 | 6k+A09PhNoorVrNnw/xmWgLf0J3CBE2jxUlq57QPYcVnFSs39w== 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_backend_secured/files/sensu-api.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDEFnHTOwgmHoFg 3 | lm6cdexY8tyPIufIZLlSVRFR1evXrn9IgSXqTmYz7r5zJYTtAqb1X9TAK6bTrsdB 4 | ZCxeS2wSkmRTQUpZtu/SiCSWJjDjmCVFxlnE5jMsojglzvXV0ro5aBvs8Xfm4SAZ 5 | QOXtjLxEQM4MJn2GYA0ZHzFZhaVq0kHIHNZ+e9Ef1DUuwsj22gM5VA7mjBsm5OY8 6 | H4hkx09GiXBsWybu8qMmk6wAT13Ti18ZzFP4aGth/iC6ta+KnATqvSUs5b99ifPQ 7 | jZB5fmIOiEfMz5QmAHbJwZOFpRsZXjRzOusjciMD1oMpJkxdT619HB/nhcPUTgqy 8 | H2jEZxnDAgMBAAECggEAK8zTqhpCjLk9rwSLOpnArHG7QKHMYl/VYYWs87m0D55j 9 | wh9PB9JxU+JdWj0kPwjboG3CiRZ3Eku1KG8m1f1E67UVgd9Qq0+IrF9KxNtNClme 10 | 4cIXpTrCbZLitddP5G5IuK//pOKfJMxeriVn9rL8Dsbm/6HNYimsY1MrY9LNi1l9 11 | zAxSAihUPI0JM0DEA+5C4vaIFiOt1ulhTXuRU94v8gjcDMnpp/rB8pP0XvpjNdzb 12 | 7LExeMrywEOnxGEju1Co5Q5jp2epDwjSowlTg+wJCu0dlCW6uWGV0umW+KwK+aQ0 13 | Z/Mo4VwE4kRO/2vth9N0tboHOL5EoDdKprk1v5E1+QKBgQDi8nqgaDlfsO4HIGPE 14 | NiQvevxQBQ7D2vElt04fYpla4iTJpmXeo35194sW40pAbt2N3/xsEAFZPGWiGWVe 15 | km8tLdF2vHHNp4wFHEjb86hu6h07XAikr+1+ZI+musn09lgH8gXmy610PJ+OLHnf 16 | Rmkfhr73EhBa2PLp4GArwq6D/wKBgQDdMKL/SkdwCUqz3Z3UP2cRBBNi0JDXCGTb 17 | jpQMvJZtrosxR9su55w5ZtIKLRPn7fR0AfRztBKUQBmEYgcp+1VkhIA5v6GGzNAj 18 | af/dVZhyXV9OPdSc5pDk+bWbrj8GxQr/5C04clVnwZ2ESNm8tulpwo2MZPPoj/vk 19 | tuN7UZZaPQKBgQCAZLhVicFzzrBLXdqzhgHgzs5yIvpgebxWHydWgDzMewZfAwG8 20 | /HguGzcYYsx+OXqkqmSvajqpFo9VLtL3txao07QeXaxwsep4dbEOpwHShia1j3Lg 21 | YRuWlyPiKujY6omRLS6DjRV7nlSSZb0pQTd1+5CMTS7thrGe+S7PcxuyVwKBgBgK 22 | WDztAtSvfdoMxUGzXm1gBwdfac6lT+j5FyhHOwZSyTgi+jSf4b/vZ/bJLXewyjft 23 | mncU5EwOp3dW/DZY5dAWAqXEKTcwfZLLy45v5jDP6zLiz3/6I1dvuIhiKOGAexCS 24 | 6UNQUe4EAi3FiTzUmIvxJFdVBZmKRLN4GUNm+7N1AoGAA9VfdyWQYTu+z0y91/ob 25 | y77j0hiG+A7HK7PNW2ZIwnhjczxuQ7Dcpk/GIqnOamrslLMNRU9zNETPRdEkoMnX 26 | I8ZyrGFKCby9FNBHpgbDFjY7+EgaoWwVjt4UhbZOQQAVVkoBS3CUSMFxs29iAun1 27 | uqY0wSO5KtVggDqqcZJpkHw= 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_backend_secured/files/sensu-dashboard.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCw4BDs5lCI2/Z4 3 | uiGkxBe18FebVNpNH3XS2hVPFx/XzRUOHjl8UGoyERGcdgF3jqQHSVVJjpYax6WQ 4 | PmlN7KlFowcFiXrdpjTLKcg2cbq27NggYFhfI8pheOHKpWq26tndT877LpydBuve 5 | 2b5Y06jaKy1P+XoyQ1JoYEHlt2XHTeyuVpmxBWZcdwNBKOG5dX9nPAnn003yd1F0 6 | LIuCq1+X6sD3ReWFNaJclWV5od29v6bodq42xzZ859noV2XiP+oLjRZhPMk7iT2n 7 | z1oJTPKYA/1t0CCMEkyjOK9TcXVUMPno00RO8vy47PlJ/8i8JwCyLMYVBbRb96wg 8 | /N+1VibjAgMBAAECggEBAKrHTdBO+MeMCsi6fy2FoJcs/omePkFk9PCnXRfGbhqB 9 | i6jcCgk7461/yY9WaUg006+tYMnrAIfO6M8DU83HihEQvgDco2NLzYG0T/oxiWSB 10 | /pQUMn96IThH7UsquITw8Xa8Tk88zD7ZpfjAKQe/JjOwqMmlShUp53GcL0RL9due 11 | huI8QBzbiKvBUMME1A8yaNbyy6BwHBjxfJHXaSeNwmUnlKS0A/jMNKtav8jCfdnt 12 | QEuBdL4kexZf/lt+Mu6PmODoeT8VZRrxEf4v79MZxJZNTLOVUjIhELQF1UESkbqI 13 | RoU1vVzU7CsbOWHAaym7ShZK3QDzfnVLkhFAEwsRPsECgYEA6n+SULpYTR7CtBlw 14 | zVSPePe8CiA2W28VoQrXk/9FY/j1o2cGyHidl0mVuagIROW+LyCv+HQxinJzSQrK 15 | AW/aoPgrUUfkTbpmxrPvM5FszG5cVkdFYMsW2Ni/CY8LCRdUReICdEl5xDMMfB2e 16 | /yM6oNFh7LLNrSwUsGlifJ7OcPMCgYEAwRflbOzB98lV6guQJRQISqO4+9OCIXJL 17 | ZDoHxaJ9TVr3cEFUYfm7gFvtgn2QFlqgfCN1omY3vlTuYp4llFw/Z4NX9F673erU 18 | jtt26C1pxmC7kdGApupz+gVWSqO4WhOSgpEUErUX9aX+YEy6UmdzkHnb/1cyT1eG 19 | lVvz2/eUblECgYA9aw5agIQSJuVeIG+wB97QEyq4CDnUduLWXC2cgLae+Zz0oE5h 20 | gV3dOxOxHbaUvQuz8j7Et0ImfdV+IwpHmBFOKdHGpyq/xPuYPZaADi3N2XXrzxz3 21 | vhmM0DAxA7sjNW4II6r65Ce1YJ17gJKdRo/bgRvB0A8YtTvx/JgkBcASSwKBgBzx 22 | 2BJb6zeZlqde1Fy6hAOsRy54pikdWO/NQxz9HotZ9318TYniRZkYLqJA8DhpnWT+ 23 | a8PMTs7ZLGLcEgYLTfXWWnjnOoIpkXNYsppbNF/oYDWbkg1zV69C3YySvi/Cf1PT 24 | K48iVlUcbOVCmyt/FnOx0KiWCZSbKjF5dzSiCD4BAoGAeWRARbEkptVmG1iBdhU1 25 | SNy1WhNU2L6TfUEbevYWWElQYZiQmwR4XvOfRaR3Dx8pTicABqcAwLgYPbqzCknu 26 | QcPULpLU/EJKP9xRhZClJVSJZ7JRHQrZt/i0WRVuTCCtafp50dns0vMYWBF4vVrE 27 | KUa5kMVzh3unaWHUCJ7qODw= 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_backend_secured/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | scenario: 3 | test_sequence: 4 | - destroy 5 | - create 6 | - prepare 7 | - converge 8 | - destroy 9 | 10 | platforms: 11 | - name: centos 12 | image: quay.io/xlab-steampunk/sensu-go-tests-centos:7 13 | pre_build_image: true 14 | pull: true 15 | override_command: false 16 | privileged: true 17 | volumes: 18 | - /sys/fs/cgroup:/sys/fs/cgroup:rw 19 | cgroupns_mode: host 20 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_backend_secured/prepare.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Prepare 3 | hosts: all 4 | 5 | tasks: 6 | - name: Create sensu group 7 | group: 8 | name: sensu 9 | 10 | - name: Create sensu user 11 | # We need FQCN here because we are running test from within the 12 | # collection. In this case, our collection becomes the default 13 | # collection and so the sensu.sensu_go.user module shadows the builtin 14 | # one. 15 | ansible.builtin.user: 16 | name: sensu 17 | groups: sensu 18 | 19 | - name: Create /etc/sensu folder 20 | file: 21 | state: directory 22 | path: /etc/sensu 23 | owner: sensu 24 | group: sensu 25 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_install_custom_build/converge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Test different version builds 3 | hosts: all 4 | tasks: 5 | - name: Install a specific build 6 | include_role: 7 | name: sensu.sensu_go.install 8 | vars: 9 | components: [sensu-go-backend] 10 | channel: testing 11 | version: 5.16.0 12 | build: 8290 13 | 14 | - package_facts: 15 | manager: auto 16 | 17 | - assert: 18 | that: 19 | - ansible_facts.packages["sensu-go-backend"][0].version == "5.16.0-8290" 20 | when: ansible_facts.packages["sensu-go-backend"][0].source == "apt" 21 | 22 | - assert: 23 | that: 24 | - ansible_facts.packages["sensu-go-backend"][0].version == "5.16.0" 25 | - ansible_facts.packages["sensu-go-backend"][0].release == "8290" 26 | when: ansible_facts.packages["sensu-go-backend"][0].source == "rpm" 27 | 28 | - name: Update to a specific build 29 | include_role: 30 | name: sensu.sensu_go.install 31 | tasks_from: packages 32 | vars: 33 | components: [sensu-go-backend] 34 | channel: testing 35 | version: 5.16.0 36 | build: 8320 37 | 38 | - package_facts: 39 | manager: auto 40 | 41 | - assert: 42 | that: 43 | - ansible_facts.packages["sensu-go-backend"][0].version == "5.16.0-8320" 44 | when: ansible_facts.packages["sensu-go-backend"][0].source == "apt" 45 | 46 | - assert: 47 | that: 48 | - ansible_facts.packages["sensu-go-backend"][0].version == "5.16.0" 49 | - ansible_facts.packages["sensu-go-backend"][0].release == "8320" 50 | when: ansible_facts.packages["sensu-go-backend"][0].source == "rpm" 51 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_install_custom_build/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platforms: 3 | - name: ubuntu 4 | image: quay.io/xlab-steampunk/sensu-go-tests-ubuntu:18.04 5 | pre_build_image: true 6 | pull: true 7 | 8 | - name: centos 9 | image: quay.io/xlab-steampunk/sensu-go-tests-centos:7 10 | pre_build_image: true 11 | pull: true 12 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_install_custom_version/converge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge with older versions of components 3 | hosts: all 4 | 5 | tasks: 6 | - name: Install all components 7 | include_role: 8 | name: sensu.sensu_go.install 9 | vars: 10 | components: 11 | - sensu-go-backend 12 | - sensu-go-agent 13 | - sensu-go-cli 14 | version: 5.14.1 15 | 16 | - name: Make sure components are installed 17 | command: 18 | cmd: "{{ item }} version" 19 | loop: 20 | - sensu-backend 21 | - sensu-agent 22 | - sensuctl 23 | register: result 24 | 25 | - assert: 26 | quiet: true 27 | that: 28 | - item.stdout is search("5.14.1") 29 | loop: "{{ result.results }}" 30 | loop_control: 31 | label: "{{ item.item }}" # Reduce verbosity a bit 32 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_install_custom_version/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platforms: 3 | - name: ubuntu 4 | image: quay.io/xlab-steampunk/sensu-go-tests-ubuntu:18.04 5 | pre_build_image: true 6 | pull: true 7 | 8 | - name: centos 9 | image: quay.io/xlab-steampunk/sensu-go-tests-centos:7 10 | pre_build_image: true 11 | pull: true 12 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_install_default_deb/converge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge with latest versions of components 3 | hosts: all 4 | 5 | tasks: 6 | - name: Install all components 7 | include_role: 8 | name: sensu.sensu_go.install 9 | vars: 10 | components: 11 | - sensu-go-backend 12 | - sensu-go-agent 13 | - sensu-go-cli 14 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_install_default_deb/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | scenario: 3 | test_sequence: 4 | - destroy 5 | - create 6 | - converge 7 | - verify 8 | - check 9 | - destroy 10 | 11 | platforms: 12 | - name: debian-9 13 | image: quay.io/xlab-steampunk/sensu-go-tests-debian:9 14 | pre_build_image: true 15 | pull: true 16 | 17 | - name: debian-10 18 | image: quay.io/xlab-steampunk/sensu-go-tests-debian:10 19 | pre_build_image: true 20 | pull: true 21 | 22 | - name: ubuntu-14.04 23 | image: quay.io/xlab-steampunk/sensu-go-tests-ubuntu:14.04 24 | pre_build_image: true 25 | pull: true 26 | 27 | - name: ubuntu-16.04 28 | image: quay.io/xlab-steampunk/sensu-go-tests-ubuntu:16.04 29 | pre_build_image: true 30 | pull: true 31 | 32 | - name: ubuntu-18.04 33 | image: quay.io/xlab-steampunk/sensu-go-tests-ubuntu:18.04 34 | pre_build_image: true 35 | pull: true 36 | 37 | - name: ubuntu-20.04 38 | image: quay.io/xlab-steampunk/sensu-go-tests-ubuntu:20.04 39 | pre_build_image: true 40 | pull: true 41 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_install_default_deb/verify.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Verify 3 | hosts: all 4 | 5 | tasks: 6 | - name: Make sure components are installed 7 | command: 8 | cmd: "{{ item }} version" 9 | loop: 10 | - sensu-backend 11 | - sensu-agent 12 | - sensuctl 13 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_install_default_rpm/converge.yml: -------------------------------------------------------------------------------- 1 | ../role_install_default_deb/converge.yml -------------------------------------------------------------------------------- /tests/integration/molecule/role_install_default_rpm/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | scenario: 3 | test_sequence: 4 | - destroy 5 | - create 6 | - converge 7 | - verify 8 | - check 9 | - destroy 10 | 11 | platforms: 12 | - name: redhat-7 13 | image: quay.io/xlab-steampunk/sensu-go-tests-redhat:7 14 | pre_build_image: true 15 | pull: true 16 | 17 | - name: amazon-1 18 | image: quay.io/xlab-steampunk/sensu-go-tests-amazon:1 19 | pre_build_image: true 20 | pull: true 21 | 22 | - name: amazon-2 23 | image: quay.io/xlab-steampunk/sensu-go-tests-amazon:2 24 | pre_build_image: true 25 | pull: true 26 | 27 | - name: oracle-8 28 | image: quay.io/xlab-steampunk/sensu-go-tests-oracle:8 29 | pre_build_image: true 30 | pull: true 31 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_install_default_rpm/verify.yml: -------------------------------------------------------------------------------- 1 | ../role_install_default_deb/verify.yml -------------------------------------------------------------------------------- /tests/integration/molecule/role_install_downgrade/converge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Test downgrade 3 | hosts: all 4 | 5 | tasks: 6 | - name: Install initial version components 7 | include_role: 8 | name: sensu.sensu_go.install 9 | vars: 10 | components: 11 | - sensu-go-agent 12 | version: 6.2.5 13 | 14 | - name: Make sure components are installed 15 | command: 16 | cmd: sensu-agent version 17 | register: result 18 | - assert: 19 | # quiet: true 20 | that: 21 | - result.stdout is search("6.2.5") 22 | 23 | - name: Downgrade components 24 | include_role: 25 | name: sensu.sensu_go.install 26 | tasks_from: packages 27 | vars: 28 | components: 29 | - sensu-go-agent 30 | version: 6.1.4 31 | 32 | - name: Make sure components were downgraded 33 | command: 34 | cmd: sensu-agent version 35 | register: result 36 | - assert: 37 | quiet: true 38 | that: 39 | - result.stdout is search("6.1.4") 40 | -------------------------------------------------------------------------------- /tests/integration/molecule/role_install_downgrade/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platforms: 3 | # yum test 4 | - name: redhat-7 5 | image: quay.io/xlab-steampunk/sensu-go-tests-redhat:7 6 | pre_build_image: true 7 | pull: true 8 | 9 | # apt test 10 | - name: debian-10 11 | image: quay.io/xlab-steampunk/sensu-go-tests-debian:10 12 | pre_build_image: true 13 | pull: true 14 | -------------------------------------------------------------------------------- /tests/sanity/ignore-2.10.txt: -------------------------------------------------------------------------------- 1 | plugins/modules/bonsai_asset.py validate-modules:nonexistent-parameter-documented # This is not a real module, more helper for the asset module 2 | tests/unit/plugins/module_utils/test_utils.py pylint:ansible-deprecated-no-collection-name # sanity misdetects this as module deprecation call 3 | tools/windows-versions.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints 4 | tests/sanity/validate-role-metadata.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints 5 | -------------------------------------------------------------------------------- /tests/sanity/ignore-2.11.txt: -------------------------------------------------------------------------------- 1 | plugins/modules/bonsai_asset.py validate-modules:nonexistent-parameter-documented # This is not a real module, more helper for the asset module 2 | tests/unit/plugins/module_utils/test_utils.py pylint:ansible-deprecated-no-collection-name # sanity misdetects this as module deprecation call 3 | tools/windows-versions.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints 4 | tests/sanity/validate-role-metadata.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints 5 | -------------------------------------------------------------------------------- /tests/sanity/ignore-2.12.txt: -------------------------------------------------------------------------------- 1 | plugins/modules/bonsai_asset.py validate-modules:nonexistent-parameter-documented # This is not a real module, more helper for the asset module 2 | tests/unit/plugins/module_utils/test_utils.py pylint:ansible-deprecated-no-collection-name # sanity misdetects this as module deprecation call 3 | tools/windows-versions.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints 4 | tests/sanity/validate-role-metadata.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints 5 | -------------------------------------------------------------------------------- /tests/sanity/ignore-2.13.txt: -------------------------------------------------------------------------------- 1 | plugins/modules/bonsai_asset.py validate-modules:nonexistent-parameter-documented # This is not a real module, more helper for the asset module 2 | tests/unit/plugins/module_utils/test_utils.py pylint:ansible-deprecated-no-collection-name # sanity misdetects this as module deprecation call 3 | tools/windows-versions.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints 4 | tests/sanity/validate-role-metadata.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints 5 | -------------------------------------------------------------------------------- /tests/sanity/ignore-2.14.txt: -------------------------------------------------------------------------------- 1 | plugins/modules/bonsai_asset.py validate-modules:nonexistent-parameter-documented # This is not a real module, more helper for the asset module 2 | tests/unit/plugins/module_utils/test_utils.py pylint:ansible-deprecated-no-collection-name # sanity misdetects this as module deprecation call 3 | tools/windows-versions.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints 4 | tests/sanity/validate-role-metadata.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints 5 | -------------------------------------------------------------------------------- /tests/sanity/ignore-2.15.txt: -------------------------------------------------------------------------------- 1 | plugins/modules/bonsai_asset.py validate-modules:nonexistent-parameter-documented # This is not a real module, more helper for the asset module 2 | tests/unit/plugins/module_utils/test_utils.py pylint:ansible-deprecated-no-collection-name # sanity misdetects this as module deprecation call 3 | tools/windows-versions.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints 4 | tests/sanity/validate-role-metadata.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints 5 | -------------------------------------------------------------------------------- /tests/sanity/ignore-2.16.txt: -------------------------------------------------------------------------------- 1 | plugins/modules/bonsai_asset.py validate-modules:nonexistent-parameter-documented # This is not a real module, more helper for the asset module 2 | tests/unit/plugins/module_utils/test_utils.py pylint!skip # Issue with depricate module in ansible devel version 3 | -------------------------------------------------------------------------------- /tests/sanity/ignore-2.9.txt: -------------------------------------------------------------------------------- 1 | plugins/modules/bonsai_asset.py validate-modules:nonexistent-parameter-documented # This is not a real module, more helper for the asset module 2 | tools/windows-versions.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints 3 | tests/sanity/validate-role-metadata.py replace-urlopen # Maintainer tools should not be bound by the general collection constraints 4 | -------------------------------------------------------------------------------- /tests/sanity/validate-role-metadata.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from __future__ import absolute_import, division, print_function 4 | __metaclass__ = type 5 | 6 | import argparse 7 | import json 8 | import os 9 | import sys 10 | 11 | import yaml 12 | 13 | import urllib.request 14 | 15 | 16 | def _get_arg_parser(): 17 | parser = argparse.ArgumentParser(description="Validate role metadata") 18 | parser.add_argument("role", nargs="+", help="role path") 19 | return parser 20 | 21 | 22 | def _validate_role_platforms(platforms): 23 | base_url = "https://galaxy.ansible.com/api/v1/platforms/?name={0}&release={1}" 24 | msgs = [] 25 | for platform in platforms: 26 | for release in platform["versions"]: 27 | url = base_url.format(platform["name"], release) 28 | f = urllib.request.urlopen(url) 29 | 30 | if len(json.loads(f.read().decode('utf-8'))["results"]) != 1: 31 | msgs.append(("ERROR", "Invalid platform '{0} {1}'".format( 32 | platform["name"], release, 33 | ))) 34 | 35 | return msgs 36 | 37 | 38 | def _validate_role(role_path): 39 | meta_file = os.path.join(role_path, "meta", "main.yml") 40 | with open(meta_file) as fd: 41 | galaxy_info = yaml.safe_load(fd)["galaxy_info"] 42 | 43 | msgs = [] 44 | msgs.extend(_validate_role_platforms(galaxy_info["platforms"])) 45 | 46 | return msgs 47 | 48 | 49 | def main(): 50 | args = _get_arg_parser().parse_args() 51 | no_msgs = 0 52 | for role in args.role: 53 | msgs = _validate_role(role) 54 | for msg in msgs: 55 | no_msgs += 1 56 | print("{0}: {1}".format(*msg)) 57 | 58 | return 0 if no_msgs == 0 else 1 59 | 60 | 61 | if __name__ == "__main__": 62 | sys.exit(main()) 63 | -------------------------------------------------------------------------------- /tests/unit/plugins/filter/test_backends.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | 3 | __metaclass__ = type 4 | 5 | import sys 6 | 7 | import pytest 8 | 9 | from ansible_collections.sensu.sensu_go.plugins.filter import backends 10 | 11 | pytestmark = pytest.mark.skipif( 12 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 13 | ) 14 | 15 | 16 | class TestBackends: 17 | def test_backends_in_groups_no_ssl(self): 18 | hostvars = { 19 | "1.2.3.4": {"inventory_hostname": "1.2.3.4"}, 20 | "1.2.3.5": {"inventory_hostname": "1.2.3.5"}, 21 | "1.2.3.6": {"inventory_hostname": "1.2.3.6"}, 22 | "1.2.3.7": {"inventory_hostname": "1.2.3.7"}, 23 | } 24 | groups = {"backends": ["1.2.3.4", "1.2.3.5"]} 25 | 26 | assert backends.backends(hostvars, groups) == [ 27 | "ws://1.2.3.4:8081", 28 | "ws://1.2.3.5:8081", 29 | ] 30 | 31 | def test_backends_in_groups_ssl(self): 32 | hostvars = { 33 | "1.2.3.4": {"inventory_hostname": "1.2.3.4"}, 34 | "1.2.3.5": {"inventory_hostname": "1.2.3.5"}, 35 | "1.2.3.6": { 36 | "inventory_hostname": "1.2.3.6", 37 | "api_key_file": "path/to/key.file", 38 | }, 39 | "1.2.3.7": {"inventory_hostname": "1.2.3.7"}, 40 | } 41 | groups = {"backends": ["1.2.3.6"]} 42 | 43 | assert backends.backends(hostvars, groups) == ["wss://1.2.3.6:8081"] 44 | 45 | def test_backends_not_in_groups(self): 46 | hostvars = { 47 | "1.2.3.4": {"inventory_hostname": "1.2.3.4"}, 48 | "1.2.3.5": {"inventory_hostname": "1.2.3.5"}, 49 | "1.2.3.6": {"inventory_hostname": "1.2.3.6"}, 50 | "1.2.3.7": {"inventory_hostname": "1.2.3.7"}, 51 | } 52 | groups = {} 53 | 54 | assert backends.backends(hostvars, groups) == [] 55 | -------------------------------------------------------------------------------- /tests/unit/plugins/filter/test_package_name.py: -------------------------------------------------------------------------------- 1 | # Copyright: (c) 2020, XLAB Steampunk 2 | # 3 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 4 | 5 | from __future__ import absolute_import, division, print_function 6 | __metaclass__ = type 7 | 8 | import sys 9 | 10 | import pytest 11 | 12 | from ansible_collections.sensu.sensu_go.plugins.filter import package_name 13 | 14 | pytestmark = pytest.mark.skipif( 15 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 16 | ) 17 | 18 | 19 | class TestPackageName: 20 | def test_yum_latest_version(self): 21 | assert "package" == package_name.package_name( 22 | "yum", "package", "latest", "latest", 23 | ) 24 | 25 | def test_yum_latest_build(self): 26 | assert "package-123" == package_name.package_name( 27 | "yum", "package", "123", "latest", 28 | ) 29 | 30 | def test_yum_selected_build(self): 31 | assert "package-123-456" == package_name.package_name( 32 | "yum", "package", "123", "456", 33 | ) 34 | 35 | def test_yum_ignore_build_if_latest_version(self): 36 | assert "package" == package_name.package_name( 37 | "yum", "package", "latest", "456", 38 | ) 39 | 40 | def test_apt_latest_version(self): 41 | assert "package" == package_name.package_name( 42 | "apt", "package", "latest", "latest", 43 | ) 44 | 45 | def test_apt_latest_build(self): 46 | assert "package=123-*" == package_name.package_name( 47 | "apt", "package", "123", "latest", 48 | ) 49 | 50 | def test_apt_selected_build(self): 51 | assert "package=123-456" == package_name.package_name( 52 | "apt", "package", "123", "456", 53 | ) 54 | 55 | def test_apt_ignore_build_if_latest_version(self): 56 | assert "package" == package_name.package_name( 57 | "apt", "package", "latest", "456", 58 | ) 59 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/common/utils.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import json 5 | 6 | from ansible.module_utils import basic 7 | from ansible.module_utils._text import to_bytes 8 | 9 | from mock import patch 10 | 11 | 12 | def set_module_args(**args): 13 | if '_ansible_remote_tmp' not in args: 14 | args['_ansible_remote_tmp'] = '/tmp' 15 | if '_ansible_keep_remote_files' not in args: 16 | args['_ansible_keep_remote_files'] = False 17 | 18 | args = json.dumps({'ANSIBLE_MODULE_ARGS': args}) 19 | basic._ANSIBLE_ARGS = to_bytes(args) 20 | 21 | 22 | class AnsibleExitJson(Exception): 23 | pass 24 | 25 | 26 | class AnsibleFailJson(Exception): 27 | pass 28 | 29 | 30 | def exit_json(*args, **kwargs): 31 | if 'changed' not in kwargs: 32 | kwargs['changed'] = False 33 | raise AnsibleExitJson(kwargs) 34 | 35 | 36 | def fail_json(*args, **kwargs): 37 | kwargs['failed'] = True 38 | raise AnsibleFailJson(kwargs) 39 | 40 | 41 | class ModuleTestCase: 42 | def setup_method(self): 43 | self.mock_module = patch.multiple( 44 | basic.AnsibleModule, exit_json=exit_json, fail_json=fail_json, 45 | ) 46 | self.mock_module.start() 47 | 48 | def teardown_method(self): 49 | self.mock_module.stop() 50 | 51 | 52 | def generate_name(test_case): 53 | return test_case['name'] 54 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_asset_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import asset_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestAssetInfo(ModuleTestCase): 23 | def test_get_all_assets(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [1, 2, 3] 26 | set_module_args(namespace="my") 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | asset_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/core/v2/namespaces/my/assets" 33 | assert context.value.args[0]["objects"] == [1, 2, 3] 34 | 35 | def test_get_single_asset(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = 4 38 | set_module_args(name="sample-asset") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | asset_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/core/v2/namespaces/default/assets/sample-asset" 45 | assert context.value.args[0]["objects"] == [4] 46 | 47 | def test_missing_single_asset(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args(name="sample-asset") 51 | 52 | with pytest.raises(AnsibleExitJson) as context: 53 | asset_info.main() 54 | 55 | assert context.value.args[0]["objects"] == [] 56 | 57 | def test_failure(self, mocker): 58 | get_mock = mocker.patch.object(utils, "get") 59 | get_mock.side_effect = errors.Error("Bad error") 60 | set_module_args(name="sample-asset") 61 | 62 | with pytest.raises(AnsibleFailJson): 63 | asset_info.main() 64 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_auth_provider_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import auth_provider_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestAuthProviderInfo(ModuleTestCase): 23 | def test_get_all_auth_providers(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [dict(spec=dict(a=1)), dict(spec=dict(b=2))] 26 | set_module_args() 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | auth_provider_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/enterprise/authentication/v2/authproviders" 33 | assert context.value.args[0]["objects"] == [dict(a=1), dict(b=2)] 34 | 35 | def test_get_single_auth_provider(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = dict(spec=dict(a=1)) 38 | set_module_args(name="sample-auth-provider") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | auth_provider_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/enterprise/authentication/v2/authproviders/sample-auth-provider" 45 | assert context.value.args[0]["objects"] == [dict(a=1)] 46 | 47 | def test_missing_single_auth_provider(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args(name="sample-auth-provider") 51 | 52 | with pytest.raises(AnsibleExitJson) as context: 53 | auth_provider_info.main() 54 | 55 | assert context.value.args[0]["objects"] == [] 56 | 57 | def test_failure(self, mocker): 58 | get_mock = mocker.patch.object(utils, "get") 59 | get_mock.side_effect = errors.Error("Bad error") 60 | set_module_args(name="sample-auth-provider") 61 | 62 | with pytest.raises(AnsibleFailJson): 63 | auth_provider_info.main() 64 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_bonsai_asset.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | 3 | __metaclass__ = type 4 | 5 | import sys 6 | 7 | import pytest 8 | 9 | from ansible_collections.sensu.sensu_go.plugins.module_utils import bonsai, errors 10 | from ansible_collections.sensu.sensu_go.plugins.modules import bonsai_asset 11 | 12 | from .common.utils import ( 13 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 14 | ) 15 | 16 | pytestmark = pytest.mark.skipif( 17 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 18 | ) 19 | 20 | 21 | class TestBonsaiAsset(ModuleTestCase): 22 | def test_success(self, mocker): 23 | bonsai_params = mocker.patch.object(bonsai, "get_asset_parameters") 24 | bonsai_params.return_value = dict(sample="value") 25 | 26 | set_module_args(name="name", version="version") 27 | 28 | with pytest.raises(AnsibleExitJson): 29 | bonsai_asset.main() 30 | 31 | def test_bonsai_failure(self, mocker): 32 | bonsai_params = mocker.patch.object(bonsai, "get_asset_parameters") 33 | bonsai_params.side_effect = errors.BonsaiError("Bonsai bad") 34 | 35 | set_module_args(name="name", version="version") 36 | 37 | with pytest.raises(AnsibleFailJson): 38 | bonsai_asset.main() 39 | 40 | def test_validation_failure(self, mocker): 41 | bonsai_params = mocker.patch.object(bonsai, "get_asset_parameters") 42 | bonsai_params.return_value = dict(sample="value") 43 | 44 | set_module_args(version="version") 45 | 46 | with pytest.raises(AnsibleFailJson): 47 | bonsai_asset.main() 48 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_check_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import check_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestSensuGoCheckInfo(ModuleTestCase): 23 | def test_get_all_checks(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [1, 2, 3] 26 | set_module_args(namespace="my") 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | check_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/core/v2/namespaces/my/checks" 33 | assert context.value.args[0]["objects"] == [1, 2, 3] 34 | 35 | def test_get_single_check(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = 4 38 | set_module_args(name="sample-check") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | check_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/core/v2/namespaces/default/checks/sample-check" 45 | assert context.value.args[0]["objects"] == [4] 46 | 47 | def test_missing_single_check(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args(name="sample-check") 51 | 52 | with pytest.raises(AnsibleExitJson) as context: 53 | check_info.main() 54 | 55 | assert context.value.args[0]["objects"] == [] 56 | 57 | def test_failure(self, mocker): 58 | get_mock = mocker.patch.object(utils, "get") 59 | get_mock.side_effect = errors.Error("Bad error") 60 | set_module_args(name="sample-check") 61 | 62 | with pytest.raises(AnsibleFailJson): 63 | check_info.main() 64 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_cluster_role_binding_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import cluster_role_binding_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestClusterRoleBindingInfo(ModuleTestCase): 23 | def test_get_all_cluster_role_bindings(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [1, 2, 3] 26 | set_module_args() 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | cluster_role_binding_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/core/v2/clusterrolebindings" 33 | assert context.value.args[0]["objects"] == [1, 2, 3] 34 | 35 | def test_get_single_cluster_role_binding(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = 1 38 | set_module_args(name="test-cluster-role-binding") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | cluster_role_binding_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/core/v2/clusterrolebindings/test-cluster-role-binding" 45 | assert context.value.args[0]["objects"] == [1] 46 | 47 | def test_missing_single_cluster_role_binding(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args(name="sample-cluster-role-binding") 51 | 52 | with pytest.raises(AnsibleExitJson) as context: 53 | cluster_role_binding_info.main() 54 | 55 | assert context.value.args[0]["objects"] == [] 56 | 57 | def test_failure(self, mocker): 58 | get_mock = mocker.patch.object(utils, "get") 59 | get_mock.side_effect = errors.Error("Bad error") 60 | set_module_args(name="sample-cluster-role-binding") 61 | 62 | with pytest.raises(AnsibleFailJson): 63 | cluster_role_binding_info.main() 64 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_cluster_role_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import cluster_role_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestClusterRoleInfo(ModuleTestCase): 23 | def test_get_all_cluster_roles(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [1, 2, 3] 26 | set_module_args() 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | cluster_role_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/core/v2/clusterroles" 33 | assert context.value.args[0]["objects"] == [1, 2, 3] 34 | 35 | def test_get_single_cluster_role(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = 1 38 | set_module_args(name="test-cluster-role") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | cluster_role_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/core/v2/clusterroles/test-cluster-role" 45 | assert context.value.args[0]["objects"] == [1] 46 | 47 | def test_missing_single_cluster_role(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args(name="sample-cluster-role") 51 | 52 | with pytest.raises(AnsibleExitJson) as context: 53 | cluster_role_info.main() 54 | 55 | assert context.value.args[0]["objects"] == [] 56 | 57 | def test_failure(self, mocker): 58 | get_mock = mocker.patch.object(utils, "get") 59 | get_mock.side_effect = errors.Error("Bad error") 60 | set_module_args(name="sample-cluster-role") 61 | 62 | with pytest.raises(AnsibleFailJson): 63 | cluster_role_info.main() 64 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_datastore_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import datastore_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestDatastoreInfo(ModuleTestCase): 23 | def test_get_all_datastores(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [dict(spec=1), dict(spec=2)] 26 | set_module_args() 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | datastore_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/enterprise/store/v1/provider" 33 | assert context.value.args[0]["objects"] == [1, 2] 34 | 35 | def test_get_single_datastore(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = dict(spec=4) 38 | set_module_args(name="sample-datastore") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | datastore_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/enterprise/store/v1/provider/sample-datastore" 45 | assert context.value.args[0]["objects"] == [4] 46 | 47 | def test_missing_single_datastore(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args(name="sample-datastore") 51 | 52 | with pytest.raises(AnsibleExitJson) as context: 53 | datastore_info.main() 54 | 55 | assert context.value.args[0]["objects"] == [] 56 | 57 | def test_failure(self, mocker): 58 | get_mock = mocker.patch.object(utils, "get") 59 | get_mock.side_effect = errors.Error("Bad error") 60 | set_module_args(name="sample-datastore") 61 | 62 | with pytest.raises(AnsibleFailJson): 63 | datastore_info.main() 64 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_entity_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import entity_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestEntityInfo(ModuleTestCase): 23 | def test_get_all_entities(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [1, 2, 3] 26 | set_module_args(namespace="my") 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | entity_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/core/v2/namespaces/my/entities" 33 | assert context.value.args[0]["objects"] == [1, 2, 3] 34 | 35 | def test_get_single_entity(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = 4 38 | set_module_args(name="sample-entity") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | entity_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/core/v2/namespaces/default/entities/sample-entity" 45 | assert context.value.args[0]["objects"] == [4] 46 | 47 | def test_missing_single_entity(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args(name="sample-entity") 51 | 52 | with pytest.raises(AnsibleExitJson) as context: 53 | entity_info.main() 54 | 55 | assert context.value.args[0]["objects"] == [] 56 | 57 | def test_failure(self, mocker): 58 | get_mock = mocker.patch.object(utils, "get") 59 | get_mock.side_effect = errors.Error("Bad error") 60 | set_module_args(name="sample-entity") 61 | 62 | with pytest.raises(AnsibleFailJson): 63 | entity_info.main() 64 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_filter_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import filter_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestFilterInfo(ModuleTestCase): 23 | def test_get_all_filters(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [1, 2, 3] 26 | set_module_args(namespace="my") 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | filter_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/core/v2/namespaces/my/filters" 33 | assert context.value.args[0]["objects"] == [1, 2, 3] 34 | 35 | def test_get_single_filter(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = 4 38 | set_module_args(name="sample-filter") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | filter_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/core/v2/namespaces/default/filters/sample-filter" 45 | assert context.value.args[0]["objects"] == [4] 46 | 47 | def test_missing_single_filter(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args(name="sample-filter") 51 | 52 | with pytest.raises(AnsibleExitJson) as context: 53 | filter_info.main() 54 | 55 | assert context.value.args[0]["objects"] == [] 56 | 57 | def test_failure(self, mocker): 58 | get_mock = mocker.patch.object(utils, "get") 59 | get_mock.side_effect = errors.Error("Bad error") 60 | set_module_args(name="sample-filter") 61 | 62 | with pytest.raises(AnsibleFailJson): 63 | filter_info.main() 64 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_handler_set.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import handler_set 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestHandlerSet(ModuleTestCase): 23 | def test_all_handler_set_parameters(self, mocker): 24 | sync_mock = mocker.patch.object(utils, "sync") 25 | sync_mock.return_value = True, {} 26 | set_module_args( 27 | name='test_handler', 28 | namespace='my', 29 | state='absent', 30 | handlers=['tcp_handler', 'udp_handler'] 31 | ) 32 | 33 | with pytest.raises(AnsibleExitJson): 34 | handler_set.main() 35 | 36 | state, _client, path, payload, check_mode = sync_mock.call_args[0] 37 | assert state == "absent" 38 | assert path == "/api/core/v2/namespaces/my/handlers/test_handler" 39 | assert payload == dict( 40 | type='set', 41 | handlers=['tcp_handler', 'udp_handler'], 42 | metadata=dict( 43 | name="test_handler", 44 | namespace="my", 45 | ), 46 | ) 47 | assert check_mode is False 48 | 49 | def test_failure(self, mocker): 50 | sync_mock = mocker.patch.object(utils, "sync") 51 | sync_mock.side_effect = errors.Error("Bad error") 52 | set_module_args( 53 | name='test_handler', 54 | state='absent', 55 | handlers=['tcp_handler', 'udp_handler'] 56 | ) 57 | 58 | with pytest.raises(AnsibleFailJson): 59 | handler_set.main() 60 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_hook_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import hook_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestHookInfo(ModuleTestCase): 23 | def test_get_all_hooks(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [1, 2, 3] 26 | set_module_args(namespace="my") 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | hook_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/core/v2/namespaces/my/hooks" 33 | assert context.value.args[0]["objects"] == [1, 2, 3] 34 | 35 | def test_get_single_hook(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = 4 38 | set_module_args(name="sample-hook") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | hook_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/core/v2/namespaces/default/hooks/sample-hook" 45 | assert context.value.args[0]["objects"] == [4] 46 | 47 | def test_missing_single_hook(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args(name="sample-hook") 51 | 52 | with pytest.raises(AnsibleExitJson) as context: 53 | hook_info.main() 54 | 55 | assert context.value.args[0]["objects"] == [] 56 | 57 | def test_failure(self, mocker): 58 | get_mock = mocker.patch.object(utils, "get") 59 | get_mock.side_effect = errors.Error("Bad error") 60 | set_module_args(name="sample-hook") 61 | 62 | with pytest.raises(AnsibleFailJson): 63 | hook_info.main() 64 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_mutator_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import mutator_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestMutatorInfo(ModuleTestCase): 23 | def test_get_all_mutators(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [1, 2, 3] 26 | set_module_args(namespace="my") 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | mutator_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/core/v2/namespaces/my/mutators" 33 | assert context.value.args[0]["objects"] == [1, 2, 3] 34 | 35 | def test_get_single_mutator(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = 4 38 | set_module_args(name="sample-mutator") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | mutator_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/core/v2/namespaces/default/mutators/sample-mutator" 45 | assert context.value.args[0]["objects"] == [4] 46 | 47 | def test_missing_single_mutator(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args(name="sample-mutator") 51 | 52 | with pytest.raises(AnsibleExitJson) as context: 53 | mutator_info.main() 54 | 55 | assert context.value.args[0]["objects"] == [] 56 | 57 | def test_failure(self, mocker): 58 | get_mock = mocker.patch.object(utils, "get") 59 | get_mock.side_effect = errors.Error("Bad error") 60 | set_module_args(name="sample-mutator") 61 | 62 | with pytest.raises(AnsibleFailJson): 63 | mutator_info.main() 64 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_namespace.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import namespace 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestNamespace(ModuleTestCase): 23 | def test_namespace(self, mocker): 24 | sync_mock = mocker.patch.object(utils, 'sync') 25 | sync_mock.return_value = True, {} 26 | set_module_args( 27 | name='dev' 28 | ) 29 | 30 | with pytest.raises(AnsibleExitJson): 31 | namespace.main() 32 | 33 | state, _client, path, payload, check_mode = sync_mock.call_args[0] 34 | assert state == 'present' 35 | assert path == '/api/core/v2/namespaces/dev' 36 | assert payload == dict( 37 | name='dev' 38 | ) 39 | assert check_mode is False 40 | 41 | def test_failure(self, mocker): 42 | sync_mock = mocker.patch.object(utils, 'sync') 43 | sync_mock.side_effect = errors.Error('Bad error') 44 | set_module_args( 45 | name='dev', 46 | ) 47 | 48 | with pytest.raises(AnsibleFailJson): 49 | namespace.main() 50 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_namespace_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import namespace_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestNamespaceInfo(ModuleTestCase): 23 | def test_get_namespaces(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [1, 2, 3] 26 | set_module_args() 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | namespace_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/core/v2/namespaces" 33 | assert context.value.args[0]["objects"] == [1, 2, 3] 34 | 35 | def test_failure(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.side_effect = errors.Error("Bad error") 38 | set_module_args() 39 | 40 | with pytest.raises(AnsibleFailJson): 41 | namespace_info.main() 42 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_pipe_handler_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import handler_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestHandlerInfo(ModuleTestCase): 23 | def test_get_all_handlers(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [1, 2, 3] 26 | set_module_args(namespace="my") 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | handler_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/core/v2/namespaces/my/handlers" 33 | assert context.value.args[0]["objects"] == [1, 2, 3] 34 | 35 | def test_get_single_handler(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = 4 38 | set_module_args(name="sample-handler") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | handler_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/core/v2/namespaces/default/handlers/sample-handler" 45 | assert context.value.args[0]["objects"] == [4] 46 | 47 | def test_missing_single_handler(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args(name="sample-handler") 51 | 52 | with pytest.raises(AnsibleExitJson) as context: 53 | handler_info.main() 54 | 55 | assert context.value.args[0]["objects"] == [] 56 | 57 | def test_failure(self, mocker): 58 | get_mock = mocker.patch.object(utils, "get") 59 | get_mock.side_effect = errors.Error("Bad error") 60 | set_module_args(name="sample-handler") 61 | 62 | with pytest.raises(AnsibleFailJson): 63 | handler_info.main() 64 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_pipeline_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import pipeline_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestPipelineInfo(ModuleTestCase): 23 | def test_get_all_pipelines(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [1, 2, 3] 26 | set_module_args(namespace="my") 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | pipeline_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/core/v2/namespaces/my/pipelines" 33 | assert context.value.args[0]["objects"] == [1, 2, 3] 34 | 35 | def test_get_single_pipeline(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = 4 38 | set_module_args(name="sample-pipeline") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | pipeline_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/core/v2/namespaces/default/pipelines/sample-pipeline" 45 | assert context.value.args[0]["objects"] == [4] 46 | 47 | def test_missing_single_mutator(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args(name="sample-pipeline") 51 | 52 | with pytest.raises(AnsibleExitJson) as context: 53 | pipeline_info.main() 54 | 55 | assert context.value.args[0]["objects"] == [] 56 | 57 | def test_failure(self, mocker): 58 | get_mock = mocker.patch.object(utils, "get") 59 | get_mock.side_effect = errors.Error("Bad error") 60 | set_module_args(name="sample-pipeline") 61 | 62 | with pytest.raises(AnsibleFailJson): 63 | pipeline_info.main() 64 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_role_binding_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import role_binding_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestRoleBindingInfo(ModuleTestCase): 23 | def test_get_all_role_bindings(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [1, 2, 3] 26 | set_module_args(namespace="my") 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | role_binding_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/core/v2/namespaces/my/rolebindings" 33 | assert context.value.args[0]["objects"] == [1, 2, 3] 34 | 35 | def test_get_single_role_binding(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = 1 38 | set_module_args(name="test-role-binding") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | role_binding_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/core/v2/namespaces/default/rolebindings/test-role-binding" 45 | assert context.value.args[0]["objects"] == [1] 46 | 47 | def test_missing_single_role_binding(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args(name="sample-role-binding") 51 | 52 | with pytest.raises(AnsibleExitJson) as context: 53 | role_binding_info.main() 54 | 55 | assert context.value.args[0]["objects"] == [] 56 | 57 | def test_failure(self, mocker): 58 | get_mock = mocker.patch.object(utils, "get") 59 | get_mock.side_effect = errors.Error("Bad error") 60 | set_module_args(name="sample-role-binding") 61 | 62 | with pytest.raises(AnsibleFailJson): 63 | role_binding_info.main() 64 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_role_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import role_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestRoleInfo(ModuleTestCase): 23 | def test_get_all_roles(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [1, 2, 3] 26 | set_module_args(namespace="my") 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | role_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/core/v2/namespaces/my/roles" 33 | assert context.value.args[0]["objects"] == [1, 2, 3] 34 | 35 | def test_get_single_role(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = 1 38 | set_module_args(name="test-role") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | role_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/core/v2/namespaces/default/roles/test-role" 45 | assert context.value.args[0]["objects"] == [1] 46 | 47 | def test_missing_single_role(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args(name="sample-role") 51 | 52 | with pytest.raises(AnsibleExitJson) as context: 53 | role_info.main() 54 | 55 | assert context.value.args[0]["objects"] == [] 56 | 57 | def test_failure(self, mocker): 58 | get_mock = mocker.patch.object(utils, "get") 59 | get_mock.side_effect = errors.Error("Bad error") 60 | set_module_args(name="sample-role") 61 | 62 | with pytest.raises(AnsibleFailJson): 63 | role_info.main() 64 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_secrets_provider_env.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import secrets_provider_env 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestSecretsProviderEnv(ModuleTestCase): 23 | def test_no_provider_parameters(self, mocker): 24 | sync_v1_mock = mocker.patch.object(utils, 'sync_v1') 25 | sync_v1_mock.return_value = True, {} 26 | set_module_args() 27 | 28 | with pytest.raises(AnsibleExitJson): 29 | secrets_provider_env.main() 30 | 31 | state, _client, path, payload, check_mode = sync_v1_mock.call_args[0] 32 | assert state == 'present' 33 | assert path == '/api/enterprise/secrets/v1/providers/env' 34 | assert payload == dict( 35 | type='Env', 36 | api_version="secrets/v1", 37 | metadata=dict(name='env'), 38 | spec={} 39 | ) 40 | assert check_mode is False 41 | 42 | def test_all_provider_parameters(self, mocker): 43 | sync_v1_mock = mocker.patch.object(utils, 'sync_v1') 44 | sync_v1_mock.return_value = True, {} 45 | set_module_args( 46 | state='present', 47 | ) 48 | 49 | with pytest.raises(AnsibleExitJson): 50 | secrets_provider_env.main() 51 | 52 | state, _client, path, payload, check_mode = sync_v1_mock.call_args[0] 53 | assert state == 'present' 54 | assert path == '/api/enterprise/secrets/v1/providers/env' 55 | assert payload == dict( 56 | type='Env', 57 | api_version="secrets/v1", 58 | metadata=dict(name='env'), 59 | spec={} 60 | ) 61 | assert check_mode is False 62 | 63 | def test_failure(self, mocker): 64 | sync_v1_mock = mocker.patch.object(utils, 'sync_v1') 65 | sync_v1_mock.side_effect = errors.Error("Bad error") 66 | set_module_args() 67 | 68 | with pytest.raises(AnsibleFailJson): 69 | secrets_provider_env.main() 70 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_secrets_provider_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import secrets_provider_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestSecretsProviderInfo(ModuleTestCase): 23 | def test_get_all_secrets_providers(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [dict(spec=1), dict(spec=2)] 26 | set_module_args() 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | secrets_provider_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/enterprise/secrets/v1/providers" 33 | assert context.value.args[0]["objects"] == [1, 2] 34 | 35 | def test_get_single_secrets_provider(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = dict(spec=4) 38 | set_module_args(name="sample-secrets-provider") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | secrets_provider_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/enterprise/secrets/v1/providers/sample-secrets-provider" 45 | assert context.value.args[0]["objects"] == [4] 46 | 47 | def test_missing_single_secrets_provider(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args(name="sample-secrets-provider") 51 | 52 | with pytest.raises(AnsibleExitJson) as context: 53 | secrets_provider_info.main() 54 | 55 | assert context.value.args[0]["objects"] == [] 56 | 57 | def test_failure(self, mocker): 58 | get_mock = mocker.patch.object(utils, "get") 59 | get_mock.side_effect = errors.Error("Bad error") 60 | set_module_args(name="sample-secrets-provider") 61 | 62 | with pytest.raises(AnsibleFailJson): 63 | secrets_provider_info.main() 64 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_silence_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import silence_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestSilenceInfo(ModuleTestCase): 23 | def test_get_all_silences(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [1, 2, 3] 26 | set_module_args(namespace="my") 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | silence_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/core/v2/namespaces/my/silenced" 33 | assert context.value.args[0]["objects"] == [1, 2, 3] 34 | 35 | def test_get_single_silence(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = 4 38 | set_module_args(subscription="subscription") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | silence_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/core/v2/namespaces/default/silenced/subscription%3A%2A" # %3A = :, %2A = * 45 | assert context.value.args[0]["objects"] == [4] 46 | 47 | def test_missing_single_silence(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args( 51 | subscription="missing", 52 | check="missing", 53 | ) 54 | 55 | with pytest.raises(AnsibleExitJson) as context: 56 | silence_info.main() 57 | 58 | assert context.value.args[0]["objects"] == [] 59 | 60 | def test_failure(self, mocker): 61 | get_mock = mocker.patch.object(utils, "get") 62 | get_mock.side_effect = errors.Error("Bad error") 63 | set_module_args(check="check") 64 | 65 | with pytest.raises(AnsibleFailJson): 66 | silence_info.main() 67 | -------------------------------------------------------------------------------- /tests/unit/plugins/modules/test_user_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | __metaclass__ = type 3 | 4 | import sys 5 | 6 | import pytest 7 | 8 | from ansible_collections.sensu.sensu_go.plugins.module_utils import ( 9 | errors, utils, 10 | ) 11 | from ansible_collections.sensu.sensu_go.plugins.modules import user_info 12 | 13 | from .common.utils import ( 14 | AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args, 15 | ) 16 | 17 | pytestmark = pytest.mark.skipif( 18 | sys.version_info < (2, 7), reason="requires python2.7 or higher" 19 | ) 20 | 21 | 22 | class TestUserInfo(ModuleTestCase): 23 | def test_get_all_users(self, mocker): 24 | get_mock = mocker.patch.object(utils, "get") 25 | get_mock.return_value = [1, 2, 3] 26 | set_module_args() 27 | 28 | with pytest.raises(AnsibleExitJson) as context: 29 | user_info.main() 30 | 31 | _client, path = get_mock.call_args[0] 32 | assert path == "/api/core/v2/users" 33 | assert context.value.args[0]["objects"] == [1, 2, 3] 34 | 35 | def test_get_single_user(self, mocker): 36 | get_mock = mocker.patch.object(utils, "get") 37 | get_mock.return_value = 4 38 | set_module_args(name="sample-user") 39 | 40 | with pytest.raises(AnsibleExitJson) as context: 41 | user_info.main() 42 | 43 | _client, path = get_mock.call_args[0] 44 | assert path == "/api/core/v2/users/sample-user" 45 | assert context.value.args[0]["objects"] == [4] 46 | 47 | def test_missing_single_user(self, mocker): 48 | get_mock = mocker.patch.object(utils, "get") 49 | get_mock.return_value = None 50 | set_module_args(name="sample-user") 51 | 52 | with pytest.raises(AnsibleExitJson) as context: 53 | user_info.main() 54 | 55 | assert context.value.args[0]["objects"] == [] 56 | 57 | def test_failure(self, mocker): 58 | get_mock = mocker.patch.object(utils, "get") 59 | get_mock.side_effect = errors.Error("Bad error") 60 | set_module_args(name="sample-user") 61 | 62 | with pytest.raises(AnsibleFailJson): 63 | user_info.main() 64 | -------------------------------------------------------------------------------- /tests/unit/requirements.txt: -------------------------------------------------------------------------------- 1 | bcrypt 2 | -------------------------------------------------------------------------------- /vagrant/windows/Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |config| 2 | config.vm.define "backend" do |backend| 3 | backend.vm.box = "centos/8" 4 | backend.vm.network "private_network", ip: "192.168.50.91" 5 | backend.vm.provision "ansible" do |ansible| 6 | ansible.playbook = "back.yaml" 7 | end 8 | end 9 | 10 | config.vm.define "agent" do |agent| 11 | agent.vm.box = "gusztavvargadr/windows-10" 12 | agent.vm.hostname = "host-win" 13 | agent.vm.network "private_network", ip: "192.168.50.90" 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /vagrant/windows/back.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install backend 3 | hosts: all 4 | become: true 5 | 6 | tasks: 7 | - name: Install cli 8 | include_role: 9 | name: sensu.sensu_go.install 10 | vars: 11 | version: latest 12 | components: [sensu-go-cli] 13 | 14 | - name: Install backend 15 | include_role: 16 | name: sensu.sensu_go.backend 17 | vars: 18 | version: latest 19 | -------------------------------------------------------------------------------- /vagrant/windows/inventory.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | all: 3 | hosts: 4 | windows: 5 | ansible_host: 192.168.50.90 6 | ansible_port: 5985 7 | ansible_user: vagrant 8 | ansible_password: vagrant 9 | ansible_connection: winrm 10 | ansible_winrm_transport: basic 11 | -------------------------------------------------------------------------------- /vagrant/windows/play.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install windows agent 3 | hosts: windows 4 | 5 | tasks: 6 | - name: Install agent 7 | include_role: 8 | name: sensu.sensu_go.agent 9 | vars: 10 | version: latest 11 | agent_config: 12 | name: win 13 | backend-url: 14 | - ws://192.168.50.91:8081 15 | --------------------------------------------------------------------------------