Skip to content

Instantly share code, notes, and snippets.

View dmsimard's full-sized avatar

David Moreau Simard dmsimard

View GitHub Profile
@dmsimard
dmsimard / ara-mysql.sh
Created October 15, 2018 23:44
ara-mysql
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;"
yum -y install mariadb-server
systemctl enable --now mariadb-server
systemctl enable --now mariadb
@dmsimard
dmsimard / aplaybook.yml
Last active October 13, 2018 01:47
Zuul actions
# Pseudocode
- name: Return job status to Github
github_comment:
org: "{{ org }}" # openstack-infra
repo: "{{ repo }}" # zuul
pr: "{{ pr }}" # 1234
# Maybe jobs could supply their own comments or comment templates
comment: "{{ comment_defined_by_the_job | default('default_job_comment.j2') }}"
# +1, -2, etc
vote: "{{ vote | default(0) }}"
- name: first play
hosts: localhost
tasks:
- debug:
msg: foo
- name: second play
hosts: localhost
tasks:
- debug:
@dmsimard
dmsimard / .yaml
Last active October 10, 2018 02:25 — forked from joeysk2012/.yaml
- name: Start a new AWS with ansible enabled
hosts: workers
become: true
become_method: sudo
vars:
root_password: vptbemsq$
tasks:
- name: create sudo user
password: "{{ root_password }}"
- name: create ansadmin
[defaults]
...
# I'd like [foo] to be available to both the callback and an action plugin so I don't need to do:
# - name: Run action plugin
# action:
# server: http://api
# do: something
#
# and instead do:
@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
{
"links": [
{
"ethernet_mac_address": "fa:16:3e:ed:9a:59",
"id": "tap1a81968a-79",
"mtu": null,
"type": "bridge",
"vif_id": "1a81968a-797a-400f-8a80-567f997eb93f"
}
],
#!/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 / SmartThings_DeviceHandler.groovy
Created November 4, 2017 01:35
TH1123ZB-TH1124ZB Zigbee Sinope Thermostat
/**
Copyright Sinopé Technologies
SVN-311
**/
preferences {
// input("zipcode", "text", title: "ZipCode for setting outdoor Temp", description: "by default,use current hub location")
input("trace", "bool", title: "trace", description:
"Set it to true to enable tracing or leave it empty (no tracing)")
input("logFilter", "number",title: "(1=ERROR only,2=<1+WARNING>,3=<2+INFO>,4=<3+DEBUG>,5=<4+TRACE>)", range: "1..5",