Skip to content

Instantly share code, notes, and snippets.

View samdoran's full-sized avatar

Sam Doran samdoran

View GitHub Profile
@samdoran
samdoran / commit-msg
Last active February 4, 2019 15:16
Git commit message spell checker
#!/usr/bin/env python
import os
import shutil
import subprocess
import sys
try:
aspell_path = shutil.which('aspell')
except AttributeError:
@samdoran
samdoran / Dockerfile
Last active October 26, 2018 16:29
Dockerfile
FROM centos:7
RUN touch /tmp/foo
RUN touch /tmp/foo2
@samdoran
samdoran / out.txt
Last active August 14, 2018 21:39
Template question
z.servers:
- "server1"
- "server2"
- "server3"
bus.servers: ['server1', 'server2']
diff --git a/lib/ansible/executor/playbook_executor.py b/lib/ansible/executor/playbook_executor.py
index 46575ae79f..b72970a64a 100644
--- a/lib/ansible/executor/playbook_executor.py
+++ b/lib/ansible/executor/playbook_executor.py
@@ -102,17 +102,13 @@ class PlaybookExecutor:
# clear any filters which may have been applied to the inventory
self._inventory.remove_restriction()
- # Create a temporary copy of the play here, so we can template varibales
- # in vars_prompt fields without the templating changes affecting the original object.
@samdoran
samdoran / main.yml
Last active August 2, 2018 21:02
Ansible lookup table
# In vars/main.yml inside a role
build_commands:
docker: docker build
buildah: buildah bud
@samdoran
samdoran / deploy-steps-ternary.yml
Created July 30, 2018 21:50
Deploy steps using ternary
- name: Write the puppet step_config manifest
copy:
content: "{{ puppet_step_config is defined | ternary(puppet_step_config, lookup('file', tripleo_role_name + '/step_config.pp')) }}"
dest: /var/lib/tripleo-config/puppet_step_config.pp
force: yes
mode: '0600'
- name: Write docker-puppet.json file
copy:
content: "{{ docker_puppet_config is defined | ternary(docker_puppet_config, lookup('file', tripleo_role_name + '/puppet_config.yaml')) | from_yaml | to_json }}"
@samdoran
samdoran / test-ansible-role.sh
Last active December 23, 2021 00:00
Script for testing an Ansible role in containers
#!/bin/bash
# Test Ansile role inside container
#
# Inspired by the wonderful work of Jeff Geerling (@geerlingguy)
# https://gist.github.com/geerlingguy/73ef1e5ee45d8694570f334be385e181
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NEUTRAL='\033[0m'
@samdoran
samdoran / user.patch
Last active May 9, 2018 15:59
user patch
@@ -545,18 +545,21 @@ class User(object):
if self.expires:
current_expires = self.user_password()[1]
- # Convert days since Epoch to seconds since Epoch as struct_time
- total_seconds = int(current_expires) * 86400
- current_expires = time.gmtime(total_seconds)
+ # If the expiration date is positive, self.expires will be a struct_time
+ if isinstance(self.expires, time.struct_time):
+ # Convert days since Epoch to seconds since Epoch as struct_time
PLAY [localhost] *******************************************************************************************
TASK [debug] ***********************************************************************************************
[WARNING]: Unable to find 'files/food.txt' in expected paths (use -vvvvv to see paths)
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'Display' object has no attribute 'log'
fatal: [localhost]: FAILED! => {"msg": "Unexpected failure during module execution.", "stdout": ""}
PLAY RECAP *************************************************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1
diff --git a/lib/ansible/modules/utilities/logic/pause.py b/lib/ansible/modules/utilities/logic/pause.py
index 4f0c8db663..cbb1fe5d44 100644
--- a/lib/ansible/modules/utilities/logic/pause.py
+++ b/lib/ansible/modules/utilities/logic/pause.py
@@ -34,6 +34,7 @@ options:
prompt:
description:
- Optional text to use for the prompt message.
+ - When a custom prompt is supplied without C(minutes) or C(seconds), this puts the module in interactive mode. To abort, press Ctrl + C, then Enter.
echo: