This repository has been archived by the owner on Nov 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
1,630 additions
and
1 deletion.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @durera @whitfiea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Publish Ansible Collection | ||
on: | ||
push: | ||
branches-ignore: | ||
- '**' | ||
tags: | ||
- '**' | ||
jobs: | ||
ansible-publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2.3.1 | ||
|
||
- name: Initialise the build system | ||
run: | | ||
chmod u+x $GITHUB_WORKSPACE/build/bin/*.sh | ||
$GITHUB_WORKSPACE/build/bin/initbuild.sh | ||
source $GITHUB_WORKSPACE/build/bin/.functions.sh | ||
python -m pip install -q ansible==2.10.3 yamllint | ||
# Note: Use "--format standard" to ensure filenames and line numbers are in the output | ||
# https://gitanswer.com/yamllint-missing-filenames-and-line-numbers-in-github-action-output-python-794550803 | ||
- name: Validate that the ansible collection lints successfully | ||
run: | | ||
yamllint --format standard -c $GITHUB_WORKSPACE/yamllint.yaml $GITHUB_WORKSPACE/ibm/mas_airgap | ||
- name: Build the Ansible collection | ||
run: | | ||
$GITHUB_WORKSPACE/build/bin/build-collection.sh | ||
- name: Upload Ansible Collection | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: ${{ github.workspace }}/ibm/mas_airgap/ibm-mas_airgap-${{ env.VERSION }}.tar.gz | ||
asset_name: ibm-mas_airgap-${{ env.VERSION }}.tar.gz | ||
tag: ${{ github.ref }} | ||
overwrite: true | ||
|
||
# Publish | ||
- name: Publish Collection | ||
run: | | ||
ansible-galaxy collection publish ${{ github.workspace }}/ibm/mas_airgap/ibm-mas_airgap-${{ env.VERSION }}.tar.gz --token=${{ secrets.ANSIBLE_GALAXY_TOKEN }} | ||
- name: Install the Ansible collection in the container image | ||
run: cp $GITHUB_WORKSPACE/ibm/mas_airgap/ibm-mas_airgap-${{ env.VERSION }}.tar.gz $GITHUB_WORKSPACE/image/ansible-airgap/ibm-mas_airgap.tar.gz | ||
|
||
# Docker build | ||
- name: Build the docker image | ||
run: | | ||
$GITHUB_WORKSPACE/build/bin/docker-build.sh -n ibmmas -i ansible-airgap | ||
docker tag ibmmas/ansible-airgap ibmmas/ansible-airgap:${{ env.DOCKER_TAG }} | ||
docker tag ibmmas/ansible-airgap quay.io/ibmmas/ansible-airgap:${{ env.DOCKER_TAG }} | ||
# https://github.com/marketplace/actions/push-to-registry | ||
- name: Push the docker image | ||
id: push_to_quay | ||
uses: redhat-actions/push-to-registry@v2 | ||
with: | ||
tags: quay.io/ibmmas/ansible-airgap:${{ env.DOCKER_TAG }} | ||
username: ${{ secrets.QUAYIO_USERNAME }} | ||
password: ${{ secrets.QUAYIO_PASSWORD }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Build Ansible Collection | ||
on: | ||
push: | ||
branches: | ||
- '**' | ||
tags-ignore: | ||
- '**' | ||
jobs: | ||
build-ansible: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2.3.1 | ||
# Without this option, we don't get the tag information | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Initialise the build system | ||
run: | | ||
chmod u+x $GITHUB_WORKSPACE/build/bin/*.sh | ||
$GITHUB_WORKSPACE/build/bin/initbuild.sh | ||
source $GITHUB_WORKSPACE/build/bin/.functions.sh | ||
python -m pip install -q ansible==2.10.3 yamllint | ||
# Note: Use "--format standard" to ensure filenames and line numbers are in the output | ||
# https://gitanswer.com/yamllint-missing-filenames-and-line-numbers-in-github-action-output-python-794550803 | ||
- name: Validate that the ansible collection lints successfully | ||
run: | | ||
yamllint --format standard -c $GITHUB_WORKSPACE/yamllint.yaml $GITHUB_WORKSPACE/ibm/mas_airgap | ||
- name: Build the Ansible collection | ||
run: | | ||
$GITHUB_WORKSPACE/build/bin/build-collection.sh | ||
- name: Upload Ansible Collection | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ibm-mas_airgap-${{ env.VERSION }}.tar.gz | ||
path: ${{ github.workspace }}/ibm/mas_airgap/ibm-mas_airgap-${{ env.VERSION }}.tar.gz | ||
retention-days: 30 | ||
|
||
- name: Install the Ansible collection in the container image | ||
run: cp $GITHUB_WORKSPACE/ibm/mas_airgap/ibm-mas_airgap-${{ env.VERSION }}.tar.gz $GITHUB_WORKSPACE/image/ansible-airgap/ibm-mas_airgap.tar.gz | ||
|
||
- name: Build the docker image | ||
run: | | ||
$GITHUB_WORKSPACE/build/bin/docker-build.sh -n ibmmas -i ansible-airgap | ||
docker tag ibmmas/ansible-airgap ibmmas/ansible-airgap:${{ env.DOCKER_TAG }} | ||
docker tag ibmmas/ansible-airgap quay.io/ibmmas/ansible-airgap:${{ env.DOCKER_TAG }} | ||
# https://github.com/marketplace/actions/push-to-registry | ||
- name: Push the docker image | ||
id: push_to_quay | ||
uses: redhat-actions/push-to-registry@v2 | ||
with: | ||
tags: quay.io/ibmmas/ansible-airgap:${{ env.DOCKER_TAG }} | ||
username: ${{ secrets.QUAYIO_USERNAME }} | ||
password: ${{ secrets.QUAYIO_PASSWORD }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Build Documentation | ||
on: | ||
push: | ||
branches: | ||
- '**' | ||
tags-ignore: | ||
- '**' | ||
jobs: | ||
deploy-docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2.3.1 | ||
|
||
- name: Install and Build | ||
run: | | ||
bash build/bin/copy-role-docs.sh | ||
python -m pip install -q mkdocs | ||
mkdocs build --verbose --clean --strict | ||
- name: Deploy | ||
uses: JamesIves/github-pages-deploy-action@4.1.7 | ||
if: github.ref == 'refs/heads/master' | ||
with: | ||
branch: gh-pages | ||
folder: site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
*.DS_Store* | ||
site | ||
ibm/mas_airgap/ibm-mas_airgap-*.tar.gz | ||
pipelines/ibm-mas_airgap-clustertasks-*.yaml | ||
pipelines/dev/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
sudo: required | ||
language: python | ||
python: 3.8 | ||
services: | ||
- docker | ||
|
||
# Don't build on branches that match a semver string (ie the release tags that we create) | ||
branches: | ||
except: | ||
- /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$/ | ||
|
||
install: | ||
- chmod u+x $TRAVIS_BUILD_DIR/build/bin/*.sh | ||
- $TRAVIS_BUILD_DIR/build/bin/initbuild.sh | ||
# Python requirements to build the pages documentation website | ||
- python -m pip install -q ansible==2.10.3 mkdocs yamllint | ||
|
||
script: | ||
# 1. Validate that the ansible collection lints successfully | ||
- yamllint -c yamllint.yaml ibm/mas_airgap || travis_terminate 1 | ||
# 2. Validate that the mkdocs site builds successfully | ||
- mkdocs build --verbose --clean --strict || travis_terminate 1 | ||
# 3. Build the Ansible collection | ||
- $TRAVIS_BUILD_DIR/build/bin/build-collection.sh || travis_terminate 1 | ||
# 4. Install the Ansible collection in the container image | ||
- cp $TRAVIS_BUILD_DIR/ibm/mas_airgap/ibm-mas_airgap-$(cat $TRAVIS_BUILD_DIR/.version).tar.gz $TRAVIS_BUILD_DIR/image/ansible-airgap/ibm-mas_airgap.tar.gz || travis_terminate 1 | ||
# 5. Build and push the docker image | ||
- $TRAVIS_BUILD_DIR/build/bin/docker-build.sh -n ibmmas -i ansible-airgap || travis_terminate 1 | ||
- $TRAVIS_BUILD_DIR/build/bin/docker-push.sh || travis_terminate 1 | ||
# 6. Build the tekton clustertasks | ||
- $TRAVIS_BUILD_DIR/pipelines/bin/build-pipelines.sh || travis_terminate 1 | ||
|
||
after_success: | ||
# Publish a GitHub release with the ansible collection tgz as an assset | ||
- $TRAVIS_BUILD_DIR/build/bin/git-release.sh $TRAVIS_BUILD_DIR/ibm/mas_airgap/ibm-mas_airgap-$(cat $TRAVIS_BUILD_DIR/.version).tar.gz $TRAVIS_BUILD_DIR/pipelines/ibm-mas_airgap-clustertasks-$(cat $TRAVIS_BUILD_DIR/.version).tar.gz | ||
|
||
deploy: | ||
provider: pages | ||
skip_cleanup: true | ||
github_url: github.com | ||
github_token: $GITHUB_TOKEN | ||
verbose: true | ||
local_dir: site | ||
target_branch: gh-pages | ||
on: | ||
branch: master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# Contributing | ||
|
||
## Building the collection locally | ||
|
||
```bash | ||
cd ibm/mas_airgap | ||
|
||
TBD | ||
ansible-galaxy collection build --force && ansible-galaxy collection install ibm-mas_airgap-1.0.0.tar.gz -p /home/david/.ansible/collections --force | ||
|
||
ansible-playbook ../../playbook.yml | ||
``` | ||
|
||
```bash | ||
ansible-galaxy collection build --force | ||
ansible-galaxy collection publish ibm-mas_airgap-4.1.5.tar.gz --token=$ANSIBLE_GALAXY_TOKEN | ||
``` | ||
|
||
## Style Guide | ||
Failure to adhere to the style guide will result in a PR being rejected! | ||
|
||
### YAML file extension | ||
We want consistency and we want to follow the guidelines for the tools we are using, ideally everyone would agree on a standard extension for YAML files, but that has not been the case, so these are the guidelines for MAS: | ||
|
||
- Within the context of ansible all YAML files should use the `yml` extension. | ||
- Within the context of Operator SDK configuration, all YAML files should use the `yaml` extension | ||
|
||
In practice, when working was MAS Gen2 applications this means: | ||
- In the top level `/operator/name/` use `.yaml` (OSDK rules apply) | ||
- Under `/operator/name/config/` use `.yaml` (OSDK rules apply) | ||
- Under `/operator/name/molecule/` use `.yml` (Ansible rules override OSDK rules) | ||
- Under `/operator/name/playbooks/` use `.yml` (Ansible rules override OSDK rules) | ||
- Under `/operator/name/roles/` use `.yml` (Ansible rules override OSDK rules) | ||
|
||
When working with an Ansible collection repository it is more straightforward. Always use `.yml` | ||
|
||
### Naming Jinja Templates | ||
Within the `templates/` directory we place Jinja templates, as such the extension for these files should be `j2` rather than the extension of the format the file is a template for. In other words use `templates/subscription.yml.j2` instead of `templates/subscription.yml`. | ||
|
||
If you are using Visual Studio Code you may want to install the `Better Jinja` extension, it will provide syntax highlighting for Jinja templates. | ||
|
||
### Structure tasks using numbered sections | ||
To make the tasks easier to read use section headers as below: | ||
- The dashed line should be eactly 80 characters long | ||
- Leave two empty lines between each section | ||
- Mutliple related tasks can be grouped into each section, you do not need to create a section header for every single task. Leave a single empty line between tasks in the same section. | ||
|
||
#### Example | ||
```yaml | ||
# 1. Install the CRD | ||
# ----------------------------------------------------------------------------- | ||
- name: "Install MongoDBCommunity CRD" | ||
community.kubernetes.k8s: | ||
apply: yes | ||
definition: "{{ lookup('template', 'templates/community/crd.yml') }}" | ||
|
||
|
||
# 2. Create namespace & install RBAC | ||
# ----------------------------------------------------------------------------- | ||
- name: "Create namespace & install RBAC" | ||
community.kubernetes.k8s: | ||
apply: yes | ||
definition: "{{ lookup('template', 'templates/community/rbac.yml') }}" | ||
``` | ||
### Align debug messages | ||
To make debug easier to read when printed out by the default ansible display module all "property dump" debugging should be done as below: | ||
- Column 1 is is Left aligned, padded to 41 characters using dots | ||
- Using standard indentation, the "...." should end on column 50 | ||
#### Example | ||
```yaml | ||
- name: Debug properties | ||
debug: | ||
msg: | ||
- "MongoDb namespace ...................... {{ mongodb_namespace }}" | ||
- "MongoDb storage class .................. {{ mongodb_storage_class }}" | ||
- "MongoDb storage capacity (data) ........ {{ mongodb_storage_capacity_data }}" | ||
- "MongoDb storage capacity (logs) ........ {{ mongodb_storage_capacity_logs }}" | ||
- "MAS instance ID ........................ {{ mas_instance_id }}" | ||
``` | ||
### Task naming | ||
All tasks must be named. For tasks that are not in main.yaml of the role, they should be prefixed with an indentifier for the file that they are part of so that the Ansible logs guide the user to the appropriate part of the role. | ||
```yaml | ||
# 7. Deploy the cluster | ||
# ----------------------------------------------------------------------------- | ||
- name: "community : Create MongoDb cluster" | ||
community.kubernetes.k8s: | ||
apply: yes | ||
definition: "{{ lookup('template', 'templates/community/cr.yml') }}" | ||
``` | ||
This will lead to logs like the following when the role is executed: | ||
``` | ||
TASK [ibm.mas_airgap.mongodb : community : Create MongoDb cluster] | ||
``` | ||
### Failure condition checks | ||
All roles must provide clear feedback about missing required properties that do not have a default built into the role. | ||
- The feedback must be exact. Do not return a list of required properties, state specifically which variable is missing. | ||
- Be sure to check for empty string as well as not defined. Properties that are resolved from environment variables which are not set will be passed into the role as empty string (`""`) rather than undefined. | ||
```yaml | ||
# 0. Validate required properties | ||
# ----------------------------------------------------------------------------- | ||
- name: "community : Fail if mongodb_storage_class is not provided" | ||
when: mongodb_storage_class is not defined or mongodb_storage_class == "" | ||
fail: | ||
msg: "mongodb_storage_class property is required" | ||
|
||
- name: "community : Fail if mongodb_storage_capacity_data is not provided" | ||
when: mongodb_storage_capacity_data is not defined or mongodb_storage_capacity_data == "" | ||
fail: | ||
msg: "mongodb_storage_capacity_data property is required" | ||
|
||
- name: "community : Fail if mongodb_storage_capacity_logs is not provided" | ||
when: mongodb_storage_capacity_logs is not defined or mongodb_storage_capacity_logs == "" | ||
fail: | ||
msg: "mongodb_storage_capacity_logs property is required" | ||
|
||
- name: "community : Fail if mas_instance_id is not provided" | ||
when: mas_instance_id is not defined or mas_instance_id == "" | ||
fail: | ||
msg: "mas_instance_id property is required" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
# ansible-airgap | ||
# Ansible Airgap Collection for IBM Maximo Application Suite | ||
|
||
## Installation | ||
Install the collection direct from [Ansible Galaxy](https://galaxy.ansible.com/ibm/mas_airgap) | ||
|
||
``` | ||
ansible-galaxy collection install ibm.mas_airgap | ||
``` | ||
|
||
## Documentation | ||
[https://ibm-mas.github.io/ansible-airgap/](https://ibm-mas.github.io/ansible-airgap/) |
Oops, something went wrong.