Skip to content

Instantly share code, notes, and snippets.

View dmsimard's full-sized avatar

David Moreau Simard dmsimard

View GitHub Profile
@dmsimard
dmsimard / browser.py
Created January 12, 2021 19:55
Ansible browser module
#!/usr/bin/python3
# Copyright: (c) 2021, David Moreau-Simard <dmsimard@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = """
---
@dmsimard
dmsimard / ara-benchmarks.md
Last active November 1, 2020 01:22
ara benchmarks raw data

Some roughly formatted benchmark data.

ansible without ara enabled

time ansible-playbook -i 'localhost,' -c local tests/integration/benchmark.yaml
# ...
Executed in   11.36 secs   fish           external 
   usr time   36.54 secs    0.00 micros   36.54 secs 
 sys time 16.28 secs 583.00 micros 16.28 secs 
@dmsimard
dmsimard / poc.py
Created September 10, 2020 01:43
proof of concept: expanding a pull request link into a helpful message
#!/usr/bin/env python3
# TL;DR:
# translates https://github.com/<namespace>/<repo>/pull/<id> to:
# https://api.github.com/repos/<namespace>/<repo>/pulls/<id>
# query the endpoint and return a helpful message back
from urllib.parse import urlparse
import argparse
import requests
import os
%global srcname ara
Name: %{srcname}
Version: 1.3.2
Release: 1%{?dist}
Summary: ARA Records Ansible playbooks and makes them easier to understand and troubleshoot
License: GPLv3
URL: https://github.com/ansible-community/ara
Source0: https://pypi.io/packages/source/a/%{srcname}/%{srcname}-%{version}.tar.gz
#!/bin/bash
# Proof of concept of running playbooks in AWX and recording them in ARA
# From a vanilla CentOS8 image: https://cloud.centos.org/centos/8/x86_64/images/CentOS-8-GenericCloud-8.1.1911-20200113.3.x86_64.qcow2
# Add local bin directory to PATH so we can use things installed with "pip install --user"
export PATH=$PATH:~/.local/bin
dnf -y update
# Install Ansible and Python3
@dmsimard
dmsimard / test.py
Created September 9, 2019 14:06
http client test
#!/usr/bin/env python3
import json
# Import the client
from ara.clients.http import AraHttpClient
# Instanciate the HTTP client with an endpoint where an API server is listening
client = AraHttpClient(endpoint="https://api.demo.recordsansible.org")
print(json.dumps(client.get("/api/v1/playbooks")))
@dmsimard
dmsimard / reauth.py
Created August 20, 2019 16:37
reauth
import json
import re
from urllib import parse as urlparse
import requests
def _image_tag_from_url(image_url):
if '@' in image_url.path:
@dmsimard
dmsimard / test.py
Created June 5, 2019 16:04
ara with ansible-runner
#!/usr/bin/env python3
# Proof of concept ara with ansible-runner
# Requires https://github.com/ansible/ansible-runner/issues/219#issuecomment-496191227
import ansible_runner
import os
from ara.setup import callback_plugins
PLAYBOOK = """
- name: Test for ansible-runner
0001-run-tests-with-ara.patch
[root@bastion ansible]# cat 0001-run-tests-with-ara.patch
From af24cfe08bc33a2a63fd2ccc6736f35fd22cdc59 Mon Sep 17 00:00:00 2001
From: root <root@bastion.novalocal>
Date: Fri, 31 May 2019 12:39:49 +0000
Subject: [PATCH] run tests with ara
---
test/integration/integration.cfg | 5 +++++
test/integration/targets/ping/tasks/main.yml | 12 ++++++++++++