Skip to content

Commit

Permalink
feat: Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
willguibr committed Sep 20, 2023
0 parents commit 8b8a3a7
Show file tree
Hide file tree
Showing 165 changed files with 12,274 additions and 0 deletions.
127 changes: 127 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
# .ansible-lint

profile: production

# Allows dumping of results in SARIF format
# sarif_file: result.sarif

# exclude_paths included in this file are parsed relative to this file's location
# and not relative to the CWD of execution. CLI arguments passed to the --exclude
# option are parsed relative to the CWD of execution.
exclude_paths:
# - .cache/ # implicit unless exclude_paths is defined in config
- .github/
# - test/fixtures/formatting-before/
# - test/fixtures/formatting-prettier/
# parseable: true
# quiet: true
# strict: true
# verbosity: 1

# Mock modules or roles in order to pass ansible-playbook --syntax-check
# mock_modules:
# - zscaler.zpacloud.zpacloud_application_segment
# - zuul_return
# # note the foo.bar is invalid as being neither a module or a collection
# - fake_namespace.fake_collection.fake_module
# - fake_namespace.fake_collection.fake_module.fake_submodule
# mock_roles:
# - mocked_role
# - author.role_name # old standalone galaxy role
# - fake_namespace.fake_collection.fake_role # role within a collection

# Enable checking of loop variable prefixes in roles
# loop_var_prefix: "^(__|{role}_)"

# Enforce variable names to follow pattern below, in addition to Ansible own
# requirements, like avoiding python identifiers. To disable add `var-naming`
# to skip_list.
# var_naming_pattern: "^[a-z_][a-z0-9_]*$"

# use_default_rules: true
# Load custom rules from this specific folder
# rulesdir:
# - ./rule/directory/

# Ansible-lint is able to recognize and load skip rules stored inside
# `.ansible-lint-ignore` (or `.config/ansible-lint-ignore.txt`) files.
# To skip a rule just enter filename and tag, like "playbook.yml package-latest"
# on a new line.
# Optionally you can add comments after the tag, prefixed by "#". We discourage
# the use of skip_list below because that will hide violations from the output.
# When putting ignores inside the ignore file, they are marked as ignored, but
# still visible, making it easier to address later.
# skip_list:
# - role-name

# Ansible-lint does not automatically load rules that have the 'opt-in' tag.
# You must enable opt-in rules by listing each rule 'id' below.
enable_list:
# - args
# - empty-string-compare # opt-in
# - no-log-password # opt-in
# - no-same-owner # opt-in
# - name[prefix] # opt-in
# add yaml here if you want to avoid ignoring yaml checks when yamllint
# library is missing. Normally its absence just skips using that rule.
- yaml
# Report only a subset of tags and fully ignore any others
# tags:
# - jinja[spacing]

# Ansible-lint does not fail on warnings from the rules or tags listed below
# warn_list:
# - skip_this_tag
# - experimental # experimental is included in the implicit list
# - role-name
# - yaml[document-start] # you can also use sub-rule matches

# Some rules can transform files to fix (or make it easier to fix) identified
# errors. `ansible-lint --write` will reformat YAML files and run these transforms.
# By default it will run all transforms (effectively `write_list: ["all"]`).
# You can disable running transforms by setting `write_list: ["none"]`.
# Or only enable a subset of rule transforms by listing rules/tags here.
# write_list:
# - all

# Offline mode disables installation of requirements.yml and schema refreshing
# offline: true

# Return success if number of violations compared with previous git
# commit has not increased. This feature works only in git
# repositories.
# progressive: false

# Define required Ansible's variables to satisfy syntax check
# extra_vars:
# foo: bar
# multiline_string_variable: |
# line1
# line2
# complex_variable: ":{;\t$()"

# Uncomment to enforce action validation with tasks, usually is not
# needed as Ansible syntax check also covers it.
# skip_action_validation: false

# List of additional kind:pattern to be added at the top of the default
# match list, first match determines the file kind.
# kinds:
# - playbook: "**/examples/*.{yml,yaml}"
# - galaxy: "**/folder/galaxy.yml"
# - tasks: "**/tasks/*.yml"
# - vars: "**/vars/*.yml"
# - meta: "**/meta/main.yml"
# - yaml: "**/*.yaml-too"

# List of additional collections to allow in only-builtins rule.
# only_builtins_allow_collections:
# - example_ns.example_collection

# List of additions modules to allow in only-builtins rule.
# only_builtins_allow_modules:
# - example_module

# Allow setting custom prefix for name[prefix] rule
# task_name_prefix: "{stem} | "
53 changes: 53 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

## Describe the bug

<!--- A clear and concise description of what is wrong -->
<!--- Save the details for the next sections -->

## Expected behavior

<!--- Tell us what should happen, or how it should work -->

## Current behavior

<!--- Tell us what happens instead of the expected behavior -->

## Possible solution

<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- or ideas how to implement the addition or change -->

## Steps to reproduce

<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->

1.
2.
3.
4.

## Screenshots

<!--- Drag any screenshots of the issue here or delete this section -->

## Context

<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is useful in the real world -->

## Your Environment

<!--- Include as many relevant details about the environment you experienced the bug in -->

- Collection:
- Python:
- Ansible:
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/documentation_problem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Documentation problem
about: A typo, inaccuracy, or improvement in the documentation
title: ''
labels: documentation
assignees: ''

---

## Documentation link

<!--- Where is the documentation with the issue? -->

## Describe the problem

<!--- Is this a typo, stale information, request for improvement, inaccuracy? -->
<!--- Clearly and concisely describe the problem with the documentation -->

## Suggested fix

<!--- If possible, help us by offering a suggested fix to the problem -->
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

### Is your feature request related to a problem?

<!--- A clear and concise description of what the problem is. -->
<!--- eg. I'm always frustrated when [...] -->

### Describe the solution you'd like

<!--- A clear and concise description of what you want to happen. -->
<!--- How should it work? -->

### Describe alternatives you've considered

<!--- A clear and concise description of any alternative solutions, -->
<!--- features, or workarounds you've considered. -->

### Additional context

<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is useful in the real world -->
<!--- Drag any screenshot here to help illustrate -->
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
5 changes: 5 additions & 0 deletions .github/do-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

ansible-galaxy collection build
ansible-galaxy collection publish zscaler-zpacloud-* --server release_galaxy
ansible-galaxy collection publish zscaler-zpacloud-* --server automation_hub
18 changes: 18 additions & 0 deletions .github/publishing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Publishing to AutomationHub and Galaxy

## Publishing Process

Publishing to both AutomationHub and Galaxy is done with the same methodology per destination, but with different targets. An ```ansible.cfg``` file is used to define the targets and per-target parameters. Currently, the release process performed by GitHub Actions creates this ```ansible.cfg``` file on the fly, injecting sensitive values from GitHub secrets as required. The current sensitive values are stored in corporate vault, and the values can be sourced/refreshed from [the AutomationHub API token page](https://console.redhat.com/ansible/automation-hub/token):
- AUTOMATION_HUB_API_TOKEN -> "Load token" button on the page
- AUTOMATION_HUB_URL -> Server URL value on the page
- AUTOMATION_HUB_SSO_URL -> SSO URL value on the page

With the ```ansible.cfg``` file created and populated with the relevant values, GitHub Actions continues to publish to both Galaxy and AutomationHub, with two separate ```ansible-galaxy collection publish``` commands.

## Keeping the API Token Active

Inactive AutomationHub API tokens last for 30 days. In order to keep the token live between releases, a command described [here](https://console.redhat.com/ansible/automation-hub/token) should be executed. This command is currently executed by GitHub Actions on a regular schedule, and requires the current API token be passed as a parameter.

## Documentation/References
- https://docs.ansible.com/ansible/latest/galaxy/user_guide.html#configuring-the-ansible-galaxy-client
- https://access.redhat.com/documentation/en-us/red_hat_ansible_automation_platform/1.2/html/getting_started_with_red_hat_ansible_automation_hub/index
43 changes: 43 additions & 0 deletions .github/set-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash

SCRIPT_BASE="$(cd "$( dirname "$0")" && pwd )"
ROOT=${SCRIPT_BASE}/..

# Exit immediatly if any command exits with a non-zero status
set -e

# Usage
print_usage() {
echo "Set the app/add-on version"
echo ""
echo "Usage:"
echo " set-version.sh <new-version>"
echo ""
}

# if less than one arguments supplied, display usage
if [ $# -lt 1 ]
then
print_usage
exit 1
fi

# check whether user had supplied -h or --help . If yes display usage
if [ "$1" == "--help" ] || [ "$1" == "-h" ]; then
print_usage
exit 0
fi

# NEW_VERSION=$(echo "$1" | sed -e 's/-beta\./.b/' | sed -e 's/-alpha\./.a/')

# Set version in galaxy.yml
grep -E '^version: (.+)$' "$ROOT/galaxy.yml" >/dev/null
sed -i.bak -E "s/^version: (.+)$/version: $1/" "$ROOT/galaxy.yml" && rm "$ROOT/galaxy.yml.bak"

# Set version in docs/source/index.rst
grep -E '^Version: (.+)$' "$ROOT/docs/source/index.rst" > /dev/null
sed -i.bak -E "s/^Version: (.+)$/Version: $1/" "$ROOT/docs/source/index.rst" && rm "$ROOT/docs/source/index.rst.bak"

# Set version in pyproject.toml
grep -E '^version = ".+"$' "$ROOT/pyproject.toml" >/dev/null
sed -i.bak -E "s/^version = \".+\"$/version = \"$1\"/" "$ROOT/pyproject.toml" && rm "$ROOT/pyproject.toml.bak"
Loading

0 comments on commit 8b8a3a7

Please sign in to comment.