Skip to content

Instantly share code, notes, and snippets.

David Moreau Simard dmsimard

Block or report user

Report or block dmsimard

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ara_api.yaml
- name: Get playbooks
ara_api:
# This doesn't actually need to be specified, the module can pick it up from the callback config
# https://github.com/openstack/ara-plugins/blob/49ce188ab88a6948db651163b9cd7973117fa2b1/ara/plugins/action/ara_record.py#L143-L153
# api_server: https://api.demo.recordsansible.org
action: get
endpoint: /api/v1/playbooks
filter:
status: failed
register: failed_playbooks
@dmsimard
dmsimard / mitigate-meltdown.yml
Created Jan 9, 2018 — forked from mnaser/mitigate-meltdown.yml
Ansible playbook for Meltdown mitigation (KPI for CentOS/RHEL 7)
View mitigate-meltdown.yml
---
- hosts: all
gather_facts: false
pre_tasks:
- name: ensure ipmi tools are installed
yum:
name: ipmitool
- name: retrieve ipmitool address
shell: >
ipmitool lan print | grep '^IP Addr' | grep -v Source | cut -d':' -f2 | xargs
View tower-on-openshift.sh
#!/bin/bash
yum -y install centos-release-openshift-origin epel-release
yum -y install wget git net-tools bind-utils iptables-services bridge-utils bash-completion origin-clients docker ansible htop
sed -i '/OPTIONS=.*/c\OPTIONS="--selinux-enabled --insecure-registry 172.30.0.0/16"' /etc/sysconfig/docker
# Fix shenanigans between subscription-manager-rhsm-certificates and python-rhsm-certificates:
# - https://github.com/openshift/openshift-ansible/issues/6222
# - https://github.com/minishift/minishift/issues/2194
# - https://github.com/minishift/minishift-centos-iso/issues/251
# - https://github.com/openshift/os/issues/179
View ara-mysql.sh
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
View aplaybook.yml
# 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) }}"
View playbook.yml
- name: first play
hosts: localhost
tasks:
- debug:
msg: foo
- name: second play
hosts: localhost
tasks:
- debug:
View .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
View ansible.cfg
[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:
View test.sh
#!/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 Aug 20, 2018
Example of ARA lookup
View lookup.yml
- 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
You can’t perform that action at this time.