Skip to content

Instantly share code, notes, and snippets.

View cognifloyd's full-sized avatar

Jacob Floyd cognifloyd

  • Garland, TX
  • 23:24 (UTC -05:00)
View GitHub Profile
skills:
- name: st2_opsdroid
path: /opt/stackstorm/chatops/opsdroid-skills/st2
config:
prefix: '!'
@cognifloyd
cognifloyd / action.py
Last active May 26, 2019 04:16
Pony ORM YNBool
# coding: utf-8
from pony.orm import *
from .models import attach_models
from .config import db_config_params
db = Database()
attach_models(db)
db.bind(**db_config_params)
db.generate_mapping()
@cognifloyd
cognifloyd / playbook_tasks.yaml
Last active November 21, 2018 02:37
Example of a surprising way to use loop
- name: a loop that surprised me
stat: "{{ item }}"
loop:
- path: /some/file/path
- path: /another/file/path
- name: a loop the way I normally do it (maybe not for stat, but for modules with multiple paramaters)
stat:
path: "{{ item.path }}"
loop:
@cognifloyd
cognifloyd / inventory.yaml
Created November 20, 2018 18:42
jinja2_native & ansible-vault encrypted strings
---
ungrouped:
hosts:
localhost:
ansible_connection: local
ansible_python_interpreter: /usr/bin/python2
@cognifloyd
cognifloyd / playbook output
Last active November 20, 2018 17:42
part of playbook output showing a type_debug|value of var and then the error displayed when using that var with the group module
________________________________________
< TASK [theatro-noc.share_drive : debug] >
----------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
task path: /home/cognifloyd/p/theatro-ansiblehost/ansible-playbooks.git/roles/theatro-noc.share_drive/tasks/Linux.yaml:35
$ time (git clone [email protected]:cognifloydtest/ansible-st2.git ansible-st2.git); cd ansible-st2.git; time (for role in roles/*; do echo; echo $role; git checkout master; splitsh-lite --progress --prefix $role --target=refs/heads/ansible-role-${role##*/}; git checkout ansible-role-${role##*/}; hub create cognifloydtest/ansible-role-${role##*/}; git remote add ansible-role-${role##*/} [email protected]:cognifloydtest/ansible-role-${role##*/}.git -t master; git push ansible-role-${role##*/} -u ansible-role-${role##*/}:master; done; git checkout master)
Cloning into 'ansible-st2.git'...
remote: Counting objects: 3576, done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 3576 (delta 19), reused 30 (delta 11), pack-reused 3529
Receiving objects: 100% (3576/3576), 543.84 KiB | 2.12 MiB/s, done.
Resolving deltas: 100% (1909/1909), done.
( git clone [email protected]:cognifloydtest/ansible-st2.git) 0.08s user 0.05s system 8% cpu 1.411 total
roles/bwc
from __future__ import print_function
import eventlet
eventlet.monkey_patch()
import argparse
from nclib import TCPServer, Netcat, NetcatError, NetcatTimeout
---
# StackStorm auth
st2_auth_enable: yes
# Save credentials under /root/.st2/config
st2_save_credentials: yes
st2_auth_username: st2admin
st2_auth_password: "{{ lookup('password', '{{ my_creds_dir }}/st2-' + inventory_hostname + '-' + st2_auth_username + ' length=42' ) }}"
# MongoDB
st2mongo_db: st2
@cognifloyd
cognifloyd / 1current.yaml
Last active August 5, 2017 22:43
tasks in a role, current solution and approximated solution
- name: See if authentication is enabled in mongod.conf
check_mode: yes
lineinfile:
path: /etc/mongod.conf
insertafter: 'security:'
line: ' authorization: enabled'
register: mongo_authorization
- name: Add mongo admin when authorization is disabled
mongodb_user:
@cognifloyd
cognifloyd / pxssh.py
Created July 16, 2017 04:49
pxssh modified to support preexec_fn, dimensions, and config_file options.
from __future__ import print_function
import os
from pexpect import TIMEOUT, EOF, spawn
from pexpect.pxssh import pxssh as orig_pxssh, ExceptionPxssh
__all__ = ['ExceptionPxssh', 'pxssh']