Skip to content

Instantly share code, notes, and snippets.

@justinhennessy
justinhennessy / gist:28e82c2ec05f9081786a
Last active April 29, 2021 23:13
Parsing JSON with Ansible ...

Recently, Everyday Hero has been doing a heap of work around the automation and provisioning of resources with AWS cloud services. This entails working frequently with the AWS API.

A useful filter we have been using in Ansible is taking output from a shell action and turning it into something we can consume via variables.

An example playbook is below:

# Use an official centos
FROM centos:7
# Set the working directory to /working
WORKDIR /working
RUN yum -y update
RUN yum -y install yum-utils groupinstall development
RUN yum -y install https://centos7.iuscommunity.org/ius-release.rpm
RUN yum -y install python36u
RUN yum -y install python36u-pip
RUN yum -y install python36u-devel
=sum(
indirect(
"'sheet1'!B"&MATCH(query('sheet1'!A:A,"select A where A = '"&A2&"'"),'sheet1'!A:A,0)
):
indirect(
"'sheet1'!D"&MATCH(query('sheet1'!A:A,"select A where A = '"&A2&"'"),'sheet1'!A:A,0)
)
)
require 'aws-sdk'
require 'json'
file = File.open "example.json"
data = JSON.load file
table = ARGV.shift
data["table"] = table || data["table"]
client = Aws::Lambda::Client.new
class buildkite::install(
Pattern[/(\d+\.\d+\.\d+|installed)/] $agent_version = $buildkite::agent_version,
$agent_count = 1
) {
# more puppet code
if $agent_count > 1 {
range('2', String($agent_count)).each |$extra_agent| {
file { "/usr/lib/systemd/system/buildkite-agent${extra_agent}.service":
aws_xray_sdk
boto3
datadog
doubles
flask
flask_ask
#!/bin/bash
rm -rf modules || true
pip install -r requirements.txt -t modules
#!/bin/bash
echo "Generatating python modules directory ..."
echo "-----------------------------------------"
echo ""
docker run -v ${PWD}:/working -it python_builder
echo ""
echo "Create code artifact ..."
echo "------------------------"
https://p.datadoghq.com/sb/c98e1bdd3-4dcfa46b4f
---
steps:
- type: "waiter"
- name: "Compile themes"
command: "bin/compile"
agents:
queue: design
- type: "waiter"