Skip to content

Commit

Permalink
Merge pull request #11 from stone-payments/release/3.0.0
Browse files Browse the repository at this point in the history
New release v3.0.0
  • Loading branch information
renatocmaia authored Jun 29, 2020
2 parents 2c7d8ad + d649b5c commit ef8d6b5
Show file tree
Hide file tree
Showing 38 changed files with 1,301 additions and 303 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @stone-payments/managed-services-writer
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Specifications

- **Ansible version:**
- **Python version:**
- **Operating System:**

## Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

## What I Did

```
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
```
21 changes: 21 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!--- Provide a general summary of your changes in the Title above -->

## Description
<!--- Describe your changes in detail -->

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, tests ran to see how -->
<!--- your change affects other areas of the code, etc. -->

## Screenshots (if appropriate):

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
molecule/*/.molecule
*.pyc
molecule/*/tests/__pycache__
molecule/*/.pytest_cache
.vscode
*.log
.pytest_cache
13 changes: 13 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
extends: default

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
line-length: disable
# NOTE(retr0h): Templates no longer fail this lint rule.
# Uncomment if running old Molecule templates.
# truthy: disable
1 change: 0 additions & 1 deletion CODEOWNERS

This file was deleted.

17 changes: 17 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
python-vagrant = "*"
molecule = "==2.22"
testinfra = "*"
selinux = "*"

[packages]
ansible = "*"
pywinrm = "*"

[requires]
python_version = "3.8"
903 changes: 903 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

64 changes: 41 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
stone-payments.proxy
====================
# Stone Payments - Proxy

Role for Ansible which configures the proxy client parameters in GNU/Linux and Windows systems.

## Requirements

None.

## Usage

Just include the role and set the variables in the `defaults/main.yml` file:

```yaml
- name: configure proxy client
hosts: all
Expand All @@ -15,50 +21,62 @@ Just include the role and set the variables in the `defaults/main.yml` file:
```
## Advanced usage
You may also setup another proxy protocol than HTTP (SOCKS or SOCKS5, maybe)
and setup authentication by using the following vars:
You may also setup another proxy protocol than HTTP (SOCKS or SOCKS5, maybe) and setup authentication by using the following vars:
```yaml
proxy_proto: "http" #may be http, socks or socks5
# May be http, socks or socks5
proxy_proto: "http"
proxy_address: ""
proxy_port: ""

# To use proxy with authentication
proxy_auth: false
proxy_user: ""
proxy_pass: ""

# Configure yum and RHSM to use the proxy
proxy_redhat: false

# Used to set or remove proxy settings for Windows INet which includes Internet Explorer
proxy_win_inet: true

# Used to set, remove, or import proxy settings for Windows HTTP Services WinHTTP
proxy_win_http: false

# Sets the list of hosts that will bypass the set proxy when being accessed
proxy_whitelist:
- "127.0.0.1"
- "localhost"
```
If you're going to use authentication, you need both to inform the user/pass
and enable it by setting `proxy_auth` to true.
- If you're going to use authentication, you need both to inform the user/pass and enable it by setting `proxy_auth` to true.
- You may also pass a list in `proxy_whitelist` with names or IPs that you do not want to use the proxy and access directly.

You may also pass a list in `proxy_whitelist` with names or IPs that you do not
want to use the proxy and access directly.
## Dependencies

None.

## Testing
This role implements unit tests with [Molecule](https://molecule.readthedocs.io/) on Vagrant for Windows tests. Notice
that we only support Molecule 2.0 or greater. You can install Molecule inside a virtual environment with the following
command:
```sh
virtualenv .venv
.venv/bin/activate
pip install molecule
```
You can install Vagrant with your distro package-manager (out of scope), but you will also need some plugins to
interact with Windows trough the WinRM interface:
```sh
vagrant plugin install winrm{,-fs,-elevated}

This role to use [`molecule`](https://molecule.readthedocs.io/en/latest/) to execute your local tests and check ansible syntax. Notice that we only support Molecule 2.0 or greater. You can install molecule with:

```shell
pipenv install --dev --three
```

After having Molecule setup within the virtualenv, you can run the tests with:
After having Molecule setup, you can run the tests with this steps:

```sh
molecule converge [-s scenario_name]
molecule test [-s scenario_name]
```

Where `scenario_name` is the name of a test case under `molecule`.

## Contributing

Just open a PR. We love PRs!

## License

This code is licensed under the MIT license.
17 changes: 15 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
---
proxy_proto: "http" #may be http, socks or socks5
# May be http, socks or socks5
proxy_proto: "http"
proxy_address: ""
proxy_port: ""

# To use proxy with authentication
proxy_auth: false
proxy_user: ""
proxy_pass: ""
proxy_redhat: false #configure yum and RHSM to use the proxy

# Configure yum and RHSM to use the proxy
proxy_redhat: false

# Used to set or remove proxy settings for Windows INet which includes Internet Explorer
proxy_win_inet: true

# Used to set, remove, or import proxy settings for Windows HTTP Services WinHTTP
proxy_win_http: false

# Sets the list of hosts that will bypass the set proxy when being accessed
proxy_whitelist:
- "127.0.0.1"
- "localhost"
5 changes: 3 additions & 2 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ galaxy_info:
description: Configure a client to use a system proxy
company: Stone Payments
license: MIT
min_ansible_version: 2.0.0
min_ansible_version: 2.8.0
platforms:
- name: EL
versions:
- 7
- name: Windows
versions:
- 2016Core
- 2019
- 2016
- 2012R2
galaxy_tags:
- system
Expand Down
3 changes: 3 additions & 0 deletions molecule/default-disable/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Linux proxy disabling scenario

This scenario uses the Vagrant as driver to test the role in a situation where the proxy client would be turned off.
22 changes: 22 additions & 0 deletions molecule/default-disable/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
dependency:
name: galaxy
driver:
name: vagrant
provider:
name: virtualbox
lint:
name: yamllint
platforms:
- name: centos7
box: bento/centos-7.7
provisioner:
name: ansible
lint:
name: ansible-lint
scenario:
name: default-disable
verifier:
name: testinfra
lint:
name: flake8
6 changes: 6 additions & 0 deletions molecule/default-disable/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Disable proxy into linux host
hosts: all
become: true
roles:
- role: stone-payments.proxy
3 changes: 3 additions & 0 deletions molecule/default/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Linux proxy enabling scenario

This scenario uses the Vagrant as driver to test the role in a situation where the proxy client would be turned on.
28 changes: 28 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
dependency:
name: galaxy
driver:
name: vagrant
provider:
name: virtualbox
lint:
name: yamllint
platforms:
- name: centos7
box: bento/centos-7.7
provisioner:
name: ansible
inventory:
group_vars:
all:
proxy_address: "example.com"
proxy_port: 3128
proxy_whitelist:
- ".google.com"
- ".stone.com.br"
lint:
name: ansible-lint
verifier:
name: testinfra
lint:
name: flake8
6 changes: 6 additions & 0 deletions molecule/default/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Enable proxy into linux host
hosts: all
become: true
roles:
- role: stone-payments.proxy
1 change: 1 addition & 0 deletions molecule/windows-disable/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Windows proxy disabling scenario

This scenario uses the Vagrant as driver to test the role in a situation where the proxy client would be turned off.
1 change: 0 additions & 1 deletion molecule/windows-disable/create.yml

This file was deleted.

1 change: 0 additions & 1 deletion molecule/windows-disable/destroy.yml

This file was deleted.

6 changes: 3 additions & 3 deletions molecule/windows-disable/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ driver:
lint:
name: yamllint
platforms:
- name: proxy
box: mwrock/Windows2016
cpus: 2
- name: windows2016
box: sysnet4admin/Windows2016
memory: 2048
cpus: 2
provider_options:
gui: false
provisioner:
Expand Down
2 changes: 1 addition & 1 deletion molecule/windows-disable/playbook.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: disable proxy client
- name: Disable proxy into windows host
hosts: all
roles:
- role: stone-payments.proxy
12 changes: 0 additions & 12 deletions molecule/windows-disable/prepare.yml

This file was deleted.

Loading

0 comments on commit ef8d6b5

Please sign in to comment.