Skip to content

Instantly share code, notes, and snippets.

View juliedavila's full-sized avatar
🎃
Content

Julie Davila juliedavila

🎃
Content
View GitHub Profile
@juliedavila
juliedavila / counter.yml
Created May 18, 2016 19:24
Stateful counting mechanism
---
- name: Sequential
hosts: localhost
connection: local
vars:
basename: launch_config_
tasks:
- block:
- include_vars: config_counter.yml
@juliedavila
juliedavila / gist:ce34479712ec9e285c90d24163426d34
Created May 4, 2016 20:07
Testing Examples for Custom module dev in ansible
# Run Custom module directly Ansible 2.1+
$ ANSIBLE_MODULE_ARGS='{"state": "present", "access_key_ids": ["LKDLKJLFD"], "access_key_state": "inactive", "name": "pullrequest_testing", "iam_type": "user"}' /path/to/custom_module.py
# Run custom modules directly Ansible < 2.1
### custom_module.py
....
def main():
if '--interactive' in sys.argv:
@juliedavila
juliedavila / sample_facts.py
Last active April 29, 2016 17:36
sample facts module (needs ansible V2)
#!/usr/bin/env python
def main():
module = AnsibleModule(argument_spec=dict(
# Remove type='path' to make compatible with ansible < 2
setting_path=dict(required=True, type='path'),
delimiter=dict(required=False, default=':')
))
path = module.params['setting_path']
delimiter = module.params['delimiter']
@juliedavila
juliedavila / ec2.py
Last active April 15, 2016 00:29
Debug inventory
#!/usr/bin/env python
'''
EC2 external inventory script
=================================
Generates inventory that Ansible can understand by making API request to
AWS EC2 using the Boto library.
NOTE: This script assumes Ansible is being executed where the environment
@juliedavila
juliedavila / artdict.yml
Last active April 1, 2016 13:08
sample_dict.yml
artifacts:
- url: https://gist.githubusercontent.com/defionscode/ed6294c2eb41bfe7db79/raw/daa4859a1fc2ddf8d9f25bac29e581d2826ff15b/basic_stats.txt
dest: /tmp/myarti
- url: https://bad.endpoint.com/nothing.txt
dest: /tmp/myarti3
require 'rbvmomi'
require 'pry'
module VC::Provision
VIM = RbVmomi::VIM
def clone(other_vm_path, vm_req)
other_vm = datacenter.vmFolder.findByInventoryPath(other_vm_path)
#windows = other_vm.config.guestId.start_with?("windows")
windows = vm_req.operating_system.license
@juliedavila
juliedavila / basic_stats.txt
Created January 27, 2016 21:58
Sample Stats email body
Good Afternoon,
Processor Cores = 1
Available Memory = 1416
Operating System = RedHat 7.2
Kernel Version = 3.10.0-327.el7.x86_64
Virtualization = xen
Private IP = 172.31.2.208
@juliedavila
juliedavila / requestfunction.py
Last active January 27, 2016 18:25
requestor
from ansible.module_utils.urls import open_url
import json
def request_json(url, data=None, headers=None, method='GET', use_proxy=True,
force=False, last_mod_time=None, timeout=10, validate_certs=True,
url_username=None, url_password=None, http_agent=None, force_basic_auth=False, ignore_errors=False):
try:
r = open_url(url=url, data=data, headers=headers, method=method, use_proxy=use_proxy,
force=force, last_mod_time=last_mod_time, timeout=timeout, validate_certs=validate_certs,
url_username=url_username, url_password=url_password, http_agent=http_agent,
@juliedavila
juliedavila / setup.sh
Created January 25, 2016 21:06
HR Setup
sudo yum -y install http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm git
sudo yum -y install ansible
sudo yum -y remove epel-release
echo "host github.com\n\tHostName github.com\n\tIdentityFile /tmp/hackerrankkey\n\tUser git\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
chmod 640 ~/.ssh/config
git clone https://github.com/defionscode/HR_candidate.git fubar
exit 0
@juliedavila
juliedavila / hasher.py
Created December 19, 2015 03:50
Sample module that returns a string hashed in various ways
#!/usr/bin/python
import hashlib
def main():
module = AnsibleModule(
argument_spec = dict(
string = dict(required=True)
),