Skip to content

Instantly share code, notes, and snippets.

View sivel's full-sized avatar
😏

Matt Martz sivel

😏
View GitHub Profile
# Copyright: 2018, Matt Martz <matt@sivel.net>
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause )
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
__all__ = ['Version', 'parse']
try:
from packaging.version import LegacyVersion, Version as Pep440Version, parse
Request: <?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Header></Header><Body><RetrieveProperties xmlns="urn:vim25"><_this type="PropertyCollector">propertyCollector</_this><specSet><propSet><type>SessionManager</type><pathSet>currentSession</pathSet></propSet><objectSet><obj type="SessionManager">SessionManager</obj><skip>false</skip></objectSet></specSet></RetrieveProperties></Body></Envelope>
Response: <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><RetrievePropertiesResponse xmlns="urn:vim25"></RetrievePropertiesResponse></soapenv:Body></soapenv:Envelope>
Request: <?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Header></Header><Body><RetrieveServiceContent xmlns="urn:
diff --git a/lib/ansible/cli/__init__.py b/lib/ansible/cli/__init__.py
index 24100f10c3..361b016bd5 100644
--- a/lib/ansible/cli/__init__.py
+++ b/lib/ansible/cli/__init__.py
@@ -34,10 +34,10 @@ from abc import ABCMeta, abstractmethod
import ansible
from ansible import constants as C
-from ansible.errors import AnsibleOptionsError, AnsibleError
+from ansible.errors import AnsibleOptionsError, AnsibleError, AnsibleFileNotFound
@sivel
sivel / constants2json.py
Created June 1, 2017 20:59
Ansible constants to JSON
import ast
import json
import os
import sys
import ansible.constants as C
things = {}
op_map = {
ast.Add: '+',
@sivel
sivel / builddocs.py
Last active May 31, 2017 17:22
Build DOCUMENTATION skeleton from argument_spec for an Ansible module
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015 Matt Martz <matt@sivel.net>
# Copyright (C) 2015 Rackspace US, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@sivel
sivel / syncat.py
Last active May 15, 2017 18:33
Python file that works similarly to cat, while performing (guessed) syntax highlighting
#!/usr/bin/env python
from __future__ import print_function
import sys
from pygments import highlight
from pygments.lexers import guess_lexer
from pygments.formatters import Terminal256Formatter as Formatter
# Try to load the Solarized256Style
# https://github.com/johnmastro/solarized256-pygments
@sivel
sivel / output.txt
Last active January 26, 2017 18:48
Ansible callback plugin to print the number of remaining hosts in a task
changed: [localhost3]
4 hosts remaining: localhost0, localhost1, localhost2, localhost4
changed: [localhost2]
3 hosts remaining: localhost0, localhost1, localhost4
changed: [localhost1]
2 hosts remaining: localhost0, localhost4
changed: [localhost0]
1 hosts remaining: localhost4
changed: [localhost4]
All hosts complete
E123 closing bracket does not match indentation of opening bracket's line
E124 closing bracket does not match visual indentation
E127 continuation line over-indented for visual indent
E128 continuation line under-indented for visual indent
E201 whitespace after '('
E202 whitespace before '}'
E203 whitespace before ','
E211 whitespace before '('
E221 multiple spaces before operator
E222 multiple spaces after operator
@sivel
sivel / migrate_patch.py
Created December 6, 2016 21:44
Migrate mailbox patch for ansible repo merge
import re
import sys
import requests
DIFF_GIT_RE = re.compile(r'^(diff --git a/)([^ ]+ b/)([^ ]+)$', re.M)
STAT_RE = re.compile(r'^(\s+)([^ ]+\s+\|\s+\d+\s+[+-]+)$', re.M)
MINUS_PLUS_RE = re.compile(r'^((?:-|\+){3} [ab]/)(.+)$', re.M)
#!/bin/bash
set -x
TARGET=${1:-"ubuntu1404"}
if [[ "$TARGET" =~ centos7|fedora ]]
then
TARGET_OPTIONS="--volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
fi