Skip to content

Commit

Permalink
DSO-2017: License, code of conducts & issues template (#3)
Browse files Browse the repository at this point in the history
* DSO-2017: added conde of conduct, license and update to actions

* DSO-2017: update README

* Update .github/ISSUE_TEMPLATE/bug_report.md

Co-authored-by: Angel M. Adames <[email protected]>

* Update action.yml

Co-authored-by: Angel M. Adames <[email protected]>

* DSO-2017: solve comments

* DSO-2017: added playbook path to missing command

* DSO-2017: test deployment action

* DSO-2017: test deployment action

* DSO-2017: test deployment action

* DSO-2017: removed ansible vault pass

* DSO-2017: fix typo on tags

* DSO-2017: fix typo on tags

* DSO-2017: force colors

* DSO-2017: removed collections and env colors on action

* DSO-2017: update readme

* DSO-2017: remove readme on ansible

---------

Co-authored-by: Angel M. Adames <[email protected]>
  • Loading branch information
b-nicasio and angelmadames authored Mar 4, 2024
1 parent 9c562ac commit 6f6c814
Show file tree
Hide file tree
Showing 20 changed files with 274 additions and 20 deletions.
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Bug report
about: Create a bug report
title: ''
labels: bug, needs triage
assignees: ''
---

**Description:**
A clear and concise description of what the bug is.

**Action version:**
Specify the action version.

**Platform:**
- [ ] Ubuntu
- [ ] macOS
- [ ] Windows

**Runner type:**
- [ ] Hosted
- [ ] Self-hosted

**Repro steps:**
A description with steps to reproduce the issue. If you have a public example or repo to share, please provide the link.

**Expected behavior:**
A description of what you expected to happen.

**Actual behavior:**
A description of what is actually happening.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: feature request, needs triage
assignees: ''
---

**Description:**
Describe your proposal.

**Justification:**
Justification or a use case for your proposal.

**Are you willing to submit a PR?**
<!--- We accept contributions! -->
28 changes: 28 additions & 0 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 🚢 Deployment Action Tests

on:
pull_request:
branches:
- main

env:
ANSIBLE_FORCE_COLOR: '1'
PY_COLORS: '1'
FORCE_COLOR: '1'

jobs:
deployment_test:
runs-on: ubuntu-latest
steps:
- name: 💻 Checkout current pull-request revision code
uses: actions/checkout@v4

- name: 🚀 Test Deployment Action
uses: ./
with:
dry_run: true
playbook_name: 'stage'
ansible_tags: >-
auth,
env-vars,
info
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 gbh

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ See [action.yml](action.yml)
- uses: actions/ansible-deployment@v1
with:
# Optional. Specifies the path to the playbook
playbook_path: '.'
playbook_path: 'playbooks'

# The name of the playbook
playbook_name: ''

# Optional. Set to true to run Ansible playbooks in --check mode
dry_run: true
dry_run: false

# Specifies the AWS region name for configuration
aws_region: ''
Expand All @@ -26,15 +26,18 @@ See [action.yml](action.yml)
# Example: 'system,deployment,nginx,certbot'
ansible_tags: ''

# AWS service account access key
# The ansible working directory
workdir: 'ansible'

# Optional. AWS service account access key
aws_access_key_id: ''

# Ensure the following values are treated as secrets:

# Ansible vault password to decrypt secrets
# Optional. Ansible vault password to decrypt secrets
ansible_vault_password: ''

# AWS service account secret access key
# Optional. AWS service account secret access key
aws_secret_access_key: ''
```
Expand All @@ -45,10 +48,14 @@ Example usage:
with:
playbook_path: 'playbooks'
playbook_name: 'stage.yaml'
workdir: 'ansible'
dry_run: true
aws_region: 'us-east-1'
ansible_tags: 'system,deployment,nginx,certbot'
ansible_vault_password: ${{ secrets.ANSIBLE_VAULT_PASSWORD }}
aws_access_key_id: ${{ vars.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
ansible_tags: >-
auth,
env-vars,
info
```
30 changes: 16 additions & 14 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,40 @@ inputs:
playbook_path:
description: 'The location of the playbook'
required: false
default: '.'
default: 'playbooks'
playbook_name:
description: 'The playbook file name'
required: true
ansible_vault_password:
description: 'Ansible vault password to decrypt secrets'
required: true
required: false
dry_run:
description: 'Whenever to run Ansible on check mode'
required: false
default: 'true'
default: 'false'
aws_region:
description: 'AWS runner region'
required: true
required: false
aws_access_key_id:
description: 'AWS service account access key'
required: true
required: false
aws_secret_access_key:
description: 'AWS service account secret access key'
required: true
required: false
ansible_tags:
description: 'A comma-separated string of tags to filter which tasks to run in the playbook'
required: true
default: 'kubeconfig,info'

env:
ANSIBLE_FORCE_COLOR: '1'
PY_COLORS: '1'
workdir:
description: 'The Ansible working directory'
required: true
default: 'ansible'

runs:
using: 'composite'
steps:
- name: Configure AWS service account credentials
if: ${{ inputs.aws_access_key_id != '' }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ inputs.aws_region }}
Expand All @@ -59,7 +60,7 @@ runs:

- name: Set Ansible configuration and dry run options
shell: bash -leo pipefail {0}
working-directory: ansible
working-directory: ${{ inputs.workdir }}
run: |
set_env() { echo "$1" >> $GITHUB_ENV; }
echo "Dry Run set to: ${{ inputs.dry_run }}"
Expand All @@ -70,16 +71,17 @@ runs:
set_env "OPTS="
fi
sed -i "/- hosts:/a\ no_log: yes" playbooks/site.yml
sed -i "/- hosts:/a\ no_log: yes" ${{ inputs.playbook_path }}/site.yml
- name: Add Ansible vault password to vault key file
shell: bash -leo pipefail {0}
working-directory: ansible
if: ${{ inputs.ansible_vault_password != '' }}
working-directory: ${{ inputs.workdir }}
run: echo "${{ inputs.ansible_vault_password }}" > vault.key

- name: Running Ansible tasks
shell: bash -leo pipefail {0}
working-directory: ansible
working-directory: ${{ inputs.workdir }}
run: |
tags="${{ inputs.ansible_tags }}"
Expand Down
5 changes: 5 additions & 0 deletions ansible/.ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
skip_list:
- no-changed-when
- name[play]
- name[missing]
- ignore-errors
8 changes: 8 additions & 0 deletions ansible/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# gitignore file

*.log
*.txt
collections/
facts_cache/
tmp/
vault.key
13 changes: 13 additions & 0 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Ansible configuration

[defaults]
forks = 10
gathering = smart
interpreter_python = auto
inventory = ./hosts.yml
local_tmp = ./tmp
private_role_vars = true
roles_path = ./roles

[inventory]
enable_plugins = yaml
6 changes: 6 additions & 0 deletions ansible/hosts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
all:
children:
stage:
hosts:
stage01:
9 changes: 9 additions & 0 deletions ansible/playbooks/site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Run deployment playbook
hosts: "{{ target }}"
gather_facts: false
connection: local
roles:
- role: authentication
- role: env_vars
- role: info
4 changes: 4 additions & 0 deletions ansible/playbooks/stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- import_playbook: site.yml
vars:
target: stage
5 changes: 5 additions & 0 deletions ansible/roles/authentication/tasks/auth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Authenticate to EKS and update kubeconfig
ansible.builtin.command:
cmd:
echo "Test authentication"
4 changes: 4 additions & 0 deletions ansible/roles/authentication/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- ansible.builtin.import_tasks: auth.yml
tags:
- auth
5 changes: 5 additions & 0 deletions ansible/roles/env_vars/tasks/env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Test env
ansible.builtin.command:
cmd:
echo "Test env"
4 changes: 4 additions & 0 deletions ansible/roles/env_vars/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- ansible.builtin.import_tasks: env.yml
tags:
- env-vars
5 changes: 5 additions & 0 deletions ansible/roles/info/tasks/info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Test info
ansible.builtin.command:
cmd:
echo "Test info"
4 changes: 4 additions & 0 deletions ansible/roles/info/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- ansible.builtin.import_tasks: info.yml
tags:
- info

0 comments on commit 6f6c814

Please sign in to comment.