Skip to content

Instantly share code, notes, and snippets.

View dmsimard's full-sized avatar

David Moreau Simard dmsimard

View GitHub Profile
@dmsimard
dmsimard / test.sh
Last active October 2, 2018 22:01
ara-mysql
#!/bin/bash
yum -y install mariadb-server
systemctl enable --now mariadb
mysql -e "CREATE DATABASE ara;"
mysql -e "CREATE USER ara@localhost IDENTIFIED BY 'password';"
mysql -e "GRANT ALL PRIVILEGES ON ara.* TO ara@localhost;"
mysql -e "FLUSH PRIVILEGES;"
virtualenv ara
. ara/bin/activate
pip install ara
@dmsimard
dmsimard / lookup.yml
Last active August 20, 2018 05:01
Example of ARA lookup
- name: Do something if there are 25 changed tasks across the entire playbook
async: 45
poll: 5
debug:
msg: do something
# My brain can't memorize how to write jinja conditions properly, please accept pseudocode
# The "ara" var would probably be automatically populated and kept up to date by the callback.
# "ara.playbook" would be a variable referencing the current playbook id running in ARA
# Not sure what's the simplest way of querying ARA yet.
when: {{ lookup('ara', playbook=ara.playbook, status='changed') }} > 25
#!/usr/bin/env python
# Copyright Red Hat, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# Copyright (c) 2018 Red Hat, Inc.
#
# This file is part of ARA Records Ansible.
#
# ARA is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ARA is distributed in the hope that it will be useful,
@dmsimard
dmsimard / 00-pre.txt
Created June 22, 2018 20:14
logging-config
# pip install logging_tree
from logging_tree import printout
printout()
@dmsimard
dmsimard / output.txt
Created June 22, 2018 15:37
ara-log-reproducer
# bash test.sh 2.5.5
New python executable in /tmp/venv/bin/python
Installing setuptools, pip, wheel...done.
Installing ansible==2.5.5...
Running playbook without ARA...
[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
@dmsimard
dmsimard / playbook.yml
Created June 2, 2018 02:53
This behavior of Jinja always confuses in Ansible
- hosts: localhost
gather_facts: no
vars:
thing:
tasks:
- name: Print double quotes
debug:
msg: "{{ thing | default('empty string') }}"
- name: Print empty string
#!/usr/bin/env python
# Copyright Red Hat, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
#!/usr/bin/env python
# Copyright Red Hat, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@dmsimard
dmsimard / ara_loop.yml
Created April 9, 2018 18:27
ara_loop
- name: Create many hosts
hosts: localhost
gather_facts: no
tasks:
- name: Add one host
add_host:
ansible_connection: local
hostname: "{{ item }}"
groups: many
with_sequence: start=0 end=1024 format=host%02x