Skip to content

Commit 0850c5e

Browse files
authored
Merge pull request #59 from nirarg/integration
Enable Integration tests procedure and add CONTRIBUTING MD file
2 parents 1407689 + 6c10ba6 commit 0850c5e

File tree

6 files changed

+142
-33
lines changed

6 files changed

+142
-33
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Edit at https://www.gitignore.io/?templates=git,linux,pydev,python,windows,pycharm+all,jupyternotebook,vim,webstorm,emacs,dotenv
33
tests/output
44
tests/integration/inventory
5+
tests/integration/cloud-config-azure.ini
6+
cloud-azure_ops-*.tar.gz
57
### dotenv ###
68
.env
79

CONTRIBUTING.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Contributing to the Cloud Azure Ops Ansible Collection
2+
3+
We welcome community contributions to this collection.
4+
This guide provides clear instructions for contributors on how to set up their environment for contributing to the `cloud.azure_ops` Ansible Collection.
5+
If you find problems, please open an issue or create a Pull Request (PR) against this collection repository.
6+
7+
## Prerequisites
8+
9+
Make sure you have the following installed on your Machine:
10+
11+
1. Python3 and pip3
12+
2. Docker or Podman
13+
For more information on how containers are used with Ansible, refer to the [Containers section in the Ansible Community Documentation](https://docs.ansible.com/ansible/latest/dev_guide/testing_running_locally.html#containers).
14+
To allow managing Docker as a non-root user, refer to the [Linux post-installation steps for Docker Engine](https://docs.docker.com/engine/install/linux-postinstall/).
15+
3. Ansible
16+
This can be installed by running `pip3 install ansible`
17+
18+
## Environment Setup
19+
20+
To set up your environment for contributing to the Cloud Azure Ops Ansible Collection, follow these steps:
21+
22+
> **_NOTE:_** Make sure to replace `<working directory>` with the actual path where you want to clone the repositories and set up your environment.
23+
24+
1. **Clone The "cloud.azure_ops" Ansible Collection**:
25+
This repository, includes a variety of Ansible roles and playbooks to help automate the management of resources on Azure.
26+
```shell
27+
git clone https://github.com/redhat-cop/cloud.azure_ops.git <working directory>/ansible_collections/cloud/azure_ops
28+
```
29+
30+
2. ***Clone the "Ansible collection for Azure" repository***:
31+
The GitHub repository containing all Ansible Modules and Plugins for interacting with Azure that utilized by the Roles in this repository.
32+
```shell
33+
git clone https://github.com/ansible-collections/azure.git <working directory>/ansible_collections/azure/azcollection
34+
```
35+
36+
3. ***Prepare Azure Configuration File***:
37+
Prepare the Azure configuration file at `<working directory>/ansible_collections/cloud/azure_ops/tests/integration/cloud-config-azure.ini`. A template of this file is available in [the Ansible repository](https://github.com/ansible/ansible/blob/devel/test/lib/ansible_test/config/cloud-config-azure.ini.template). Populate the file with your appropriate credentials and resource group information.
38+
39+
## Running tests
40+
41+
To run the tests, change directory into azure_ops directory:
42+
```shell
43+
cd <working directory>/ansible_collections/cloud/azure_ops
44+
```
45+
46+
### Integration tests
47+
48+
Run Ansible Integration tests, using the following command:
49+
```shell
50+
ansible-test integration --docker
51+
```
52+
53+
To run a specific test, add the test name before the `--docker` flag:
54+
```shell
55+
ansible-test integration <test name> --docker
56+
```
57+
The <test name> should be replaced with the specific folder name under `<working directory>/ansible_collections/cloud/azure_ops/tests/integration/targets/` that you want to test.
58+
59+
### Sanity tests
60+
61+
Run Ansible Sanity tests, using the following command:
62+
```shell
63+
ansible-test sanity --docker
64+
```
65+
66+
### Lint tests
67+
68+
The project uses `ansible-lint` and `black`.
69+
To execute these tools, run:
70+
```shell
71+
tox -e linters
72+
```
73+

README.md

+3-26
Original file line numberDiff line numberDiff line change
@@ -80,34 +80,11 @@ Once installed, you can reference the cloud.azure_ops collection content by its
8080
* [Ansible Using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for more details.
8181
8282
83-
## Contributing to this collection
83+
## Testing and Development
8484
85-
We welcome community contributions to this collection. If you find problems, please open an issue or create a PR against this collection repository.
85+
* This collection is tested using GitHub Actions. To know more about CI, refer to [CI.md](CI.md).
86+
* For more information about testing and development, refer to [CONTRIBUTING.md](./CONTRIBUTING.md)
8687
87-
### Testing and Development
88-
89-
The project uses `ansible-lint` and `black`.
90-
Assuming this repository is checked out in the proper structure,
91-
e.g. `collections_root/ansible_collections/cloud/azure_ops/`, run:
92-
93-
```shell
94-
tox -e linters
95-
```
96-
97-
Sanity and unit tests are run as normal:
98-
99-
```shell
100-
ansible-test sanity
101-
```
102-
103-
There are also integration tests in the `molecule` directory which are meant to be run against an azure subscription.
104-
105-
```shell
106-
az login
107-
molecule test
108-
```
109-
110-
This collection is tested using GitHub Actions. To know more about CI, refer to [CI.md](CI.md).
11188
11289
## License
11390
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
trivial:
2+
- "Added CONTRIBUTING.md file to share development and testing guide with the community"
3+
- "Added requirements.txt file under integration directory to allow testing within container"
4+
5+
bugfixes:
6+
- "roles/azure_manage_security_group: Change azure_manage_security_group_region to be optional, as it not required when the Resource Group is already exists."
7+
- "roles/azure_manage_security_group: Fix purge_rules and rules_to_remove indentation in the arguments spec"

roles/azure_manage_security_group/meta/argument_specs.yml

+6-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ argument_specs:
1616
required: true
1717
azure_manage_security_group_region:
1818
description: Azure region.
19-
required: true
2019
azure_manage_security_group_security_group:
2120
description: Object used to provide details for a security group.
2221
type: dict
@@ -82,12 +81,12 @@ argument_specs:
8281
description: Port or range of ports from which traffic originates. Can be a string or list of strings.
8382
default: '*'
8483
type: raw
85-
purge_rules:
86-
description: If set to V(yes), removes any existing, non-default, rules that are not specified in rules above.
87-
type: bool
88-
rules_to_remove:
89-
description: List of strings representing the names of security group rules to be removed from the security group.
90-
type: list
84+
purge_rules:
85+
description: If set to V(yes), removes any existing, non-default, rules that are not specified in rules above.
86+
type: bool
87+
rules_to_remove:
88+
description: List of strings representing the names of security group rules to be removed from the security group.
89+
type: list
9190
tags:
9291
description: Dictionary of string:string pairs to assign as metadata to the security group.
9392
type: dict

tests/integration/requirements.txt

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
packaging
2+
requests[security]
3+
xmltodict
4+
msgraph-sdk==1.0.0
5+
azure-cli-core==2.34.0
6+
azure-common==1.1.11
7+
azure-identity==1.14.0
8+
azure-mgmt-authorization==2.0.0
9+
azure-mgmt-apimanagement==3.0.0
10+
azure-mgmt-batch==16.2.0
11+
azure-mgmt-cdn==11.0.0
12+
azure-mgmt-compute==26.1.0
13+
azure-mgmt-containerinstance==9.0.0
14+
azure-mgmt-core==1.3.0
15+
azure-mgmt-containerregistry==9.1.0
16+
azure-containerregistry==1.1.0
17+
azure-mgmt-containerservice==20.0.0
18+
azure-mgmt-datalake-store==1.0.0
19+
azure-mgmt-datafactory==2.0.0
20+
azure-mgmt-dns==8.0.0
21+
azure-mgmt-marketplaceordering==1.1.0
22+
azure-mgmt-monitor==3.0.0
23+
azure-mgmt-managedservices==6.0.0
24+
azure-mgmt-managementgroups==1.0.0
25+
azure-mgmt-network==19.1.0
26+
azure-mgmt-nspkg==2.0.0
27+
azure-mgmt-privatedns==1.0.0
28+
azure-mgmt-redis==13.0.0
29+
azure-mgmt-resource==21.1.0
30+
azure-mgmt-rdbms==10.0.0
31+
azure-mgmt-search==8.0.0
32+
azure-mgmt-servicebus==7.1.0
33+
azure-mgmt-sql==3.0.1
34+
azure-mgmt-storage==19.0.0
35+
azure-mgmt-trafficmanager==1.0.0b1
36+
azure-mgmt-web==6.1.0
37+
azure-nspkg==2.0.0
38+
azure-storage-blob==12.11.0
39+
azure-core==1.28.0
40+
azure-keyvault==4.2.0
41+
azure-mgmt-keyvault==10.0.0
42+
azure-mgmt-cosmosdb==6.4.0
43+
azure-mgmt-hdinsight==9.0.0
44+
azure-mgmt-devtestlabs==9.0.0
45+
azure-mgmt-loganalytics==12.0.0
46+
azure-mgmt-automation==1.0.0
47+
azure-mgmt-iothub==2.2.0
48+
azure-mgmt-recoveryservices==2.0.0
49+
azure-mgmt-recoveryservicesbackup==3.0.0
50+
azure-mgmt-notificationhubs==7.0.0
51+
azure-mgmt-eventhub==10.1.0

0 commit comments

Comments
 (0)