-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit e25407d
Showing
9 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
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,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
URL="https://exporter.akerl.app/metric" | ||
AUTH="Authorization: Bearer $EXPORTER_TOKEN" | ||
if [[ "$JOB_STATUS" == "success" ]] ; then | ||
VALUE=1 | ||
else | ||
VALUE=0 | ||
fi | ||
BODY="{\"name\":\"gh/${GITHUB_REPOSITORY}\",\"metrics\":[{\"name\":\"ghactions\",\"type\":\"gauge\",\"tags\":{\"repo\":\"${GITHUB_REPOSITORY}\"},\"value\":\"${VALUE}\"}]}" | ||
|
||
echo "$BODY" | ||
|
||
curl -i -XPOST -d "$BODY" -H"$AUTH" "$URL" |
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,42 @@ | ||
--- | ||
name: Build | ||
'on': | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- "**" | ||
pull_request_target: | ||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: "${{ github.ref_name }}" | ||
fetch-depth: 0 | ||
submodules: recursive | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.1' | ||
bundler-cache: true | ||
- name: Build | ||
run: bundle exec rake | ||
- name: Release | ||
if: "${{ github.ref == 'refs/heads/main' }}" | ||
run: | | ||
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | ||
git config --global user.name 'GitHub Actions' | ||
bundle exec rake release | ||
env: | ||
BLACKSMITH_FORGE_API_KEY: "${{ secrets.BLACKSMITH_FORGE_API_KEY }}" | ||
- name: Post to hook-exporter | ||
run: "./.github/exporter.sh" | ||
env: | ||
EXPORTER_TOKEN: "${{ secrets.EXPORTER_TOKEN }}" | ||
JOB_STATUS: "${{ job.status }}" | ||
if: always() && github.ref == 'refs/heads/main' |
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,2 @@ | ||
Gemfile.lock | ||
pkg/ |
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,8 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'puppet', '~> 8.0.1' | ||
gem 'puppet-lint', '~> 4.0.0' | ||
gem 'puppet-blacksmith', '~> 7.0.0' | ||
gem 'puppet-syntax', '~> 3.3.0' | ||
gem 'metadata-json-lint', '~> 3.0.3' | ||
gem 'voxpupuli-puppet-lint-plugins', '~> 5.0.0' |
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,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2024 Les Aker | ||
|
||
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. | ||
|
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,19 @@ | ||
puppet-frameproxy | ||
=========== | ||
|
||
[![Puppet Forge](https://img.shields.io/puppetforge/v/halyard/frameproxy.svg)](https://forge.puppetlabs.com/halyard/frameproxy) | ||
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/halyard/puppet-frameproxy/build.yml?branch=main)](https://github.com/halyard/puppet-frameproxy/actions) | ||
[![MIT Licensed](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://tldrlegal.com/license/mit-license) | ||
|
||
Module to run mitmproxy as a cache for [frame](https://github.com/akerl/frame) | ||
|
||
## Usage | ||
|
||
```puppet | ||
include frameproxy | ||
``` | ||
|
||
## License | ||
|
||
frameproxy is released under the MIT License. See the bundled LICENSE file for details. | ||
|
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,32 @@ | ||
require 'puppet_blacksmith/rake_tasks' | ||
require 'puppet-lint/tasks/puppet-lint' | ||
require 'puppet-syntax/tasks/puppet-syntax' | ||
require 'metadata-json-lint/rake_task' | ||
|
||
PuppetLint::RakeTask.new(:lint) do |config| | ||
config.fail_on_warnings = true | ||
config.relative = true | ||
config.ignore_paths = ['vendor/**/*', 'pkg/**/*'] | ||
end | ||
|
||
PuppetSyntax.exclude_paths = ["vendor/**/*"] | ||
|
||
Blacksmith::RakeTask.new do |t| | ||
t.tag_pattern = '%s' | ||
end | ||
|
||
desc 'Release a new version of the puppet module' | ||
deps = %i[module:clean test module:build module:tag module:push module:bump_commit] | ||
task :release => deps do | ||
puts 'Pushing to remote git repo' | ||
Blacksmith::Git.new.push! | ||
end | ||
|
||
desc 'Run syntax and lint checks' | ||
task test: [ | ||
:metadata_lint, | ||
:syntax, | ||
:lint | ||
] | ||
|
||
task default: [:test] |
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 @@ | ||
# @summary Configure mitmproxy instance for frame | ||
# | ||
# @param datadir sets location to store cached photos and TLS cert | ||
# @param hostname sets hostname of frame API endpoint for certificate generation | ||
# @param aws_access_key_id sets the AWS key to use for Route53 challenge | ||
# @param aws_secret_access_key sets the AWS secret key to use for the Route53 challenge | ||
# @param email sets the contact address for the certificate | ||
# @param ip sets the IP to use for mitmproxy docker container | ||
class frameproxy ( | ||
String $datadir, | ||
String $hostname, | ||
String $aws_access_key_id, | ||
String $aws_secret_access_key, | ||
String $email, | ||
String $ip = '172.17.0.4', | ||
) { | ||
$hook_script = "#!/usr/bin/env bash | ||
cat \$LEGO_CERT_KEY_PATH \$LEGO_CERT_KEY_PATH > ${datadir}/tls/cert | ||
/usr/bin/systemctl restart container@frameproxy" | ||
|
||
firewall { '100 dnat for mitmproxy': | ||
chain => 'DOCKER_EXPOSE', | ||
jump => 'DNAT', | ||
proto => 'tcp', | ||
dport => 8080, | ||
todest => "${ip}:8080", | ||
table => 'nat', | ||
} | ||
|
||
file { [ | ||
$datadir, | ||
"${datadir}/cache", | ||
"${datadir}/tls", | ||
"${datadir}/scripts", | ||
]: | ||
ensure => directory, | ||
} | ||
|
||
-> acme::certificate { $hostname: | ||
hook_script => $hook_script, | ||
aws_access_key_id => $aws_access_key_id, | ||
aws_secret_access_key => $aws_secret_access_key, | ||
email => $email, | ||
} | ||
|
||
file { "${datadir}/scripts/cache.py": | ||
ensure => file, | ||
source => 'puppet:///modules/frameproxy/cache.py', | ||
} | ||
|
||
docker::container { 'frameproxy': | ||
image => 'mitmproxy/mitmproxy', | ||
args => [ | ||
"--ip ${ip}", | ||
"-v ${datadir}/cache:/opt/cache", | ||
"-v ${datadir}/tls:/opt/tls", | ||
"-v ${datadir}/scripts:/opt/scripts", | ||
], | ||
cmd => "mitmproxy --allow-hosts ${hostname} --certs ${hostname}=/opt/tls/cert -s /opt/scrits/cache.py", | ||
require => [ | ||
], | ||
} | ||
} |
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,16 @@ | ||
{ | ||
"name": "halyard-frameproxy", | ||
"version": "0.0.1", | ||
"author": "Les Aker", | ||
"license": "MIT", | ||
"summary": "Configure mitmproxy for frame", | ||
"source": "https://github.com/halyard/puppet-frameproxy", | ||
"project_page": "https://github.com/halyard/puppet-frameproxy", | ||
"issues_url": "https://github.com/halyard/puppet-frameproxy/issues", | ||
"dependencies": [ | ||
|
||
], | ||
"operatingsystem_support": [ | ||
|
||
] | ||
} |