Skip to content

Instantly share code, notes, and snippets.

View mpdehaan's full-sized avatar

Michael DeHaan mpdehaan

View GitHub Profile
BACKGROUND
Thank you very much for your interest in contributing to Vespene. The purpose of the Vespene community is work together to create great software we can all share and use.
Vespene is licensed under the Apache 2.0 Software License.
AGREEMENT
By contributing your code to Vespene you grant the Michael DeHaan LLC a non-exclusive, irrevocable, worldwide, royalty-free, sublicenseable, transferable license under all of Your relevant intellectual property rights (including copyright, patent, and any other rights), to use, copy, prepare derivative works of, distribute and publicly perform and display the Contributions on licensing terms of the current license.
@mpdehaan
mpdehaan / gist:846f4e4ddcf60a1566677a3471dcce0a
Created November 7, 2018 03:05
Vespene subprocess example
def execute_command(build, command, input_text=None, env=None, log_command=True, output_log=True, message_log=False, timeout=None):
"""
Execute a command (a list or string) with input_text as input, appending
the output of all commands to the build log.
"""
timeout_cmd = get_timeout()
shell = True
if type(command) == list:
@mpdehaan
mpdehaan / gist:f8c85b0af733598f1d3d36ca09128ce5
Created November 11, 2018 21:35
python 3 import magic
# is there a better way to write all the code in magic_imports.py to re-surface a lot of deeply nested
# symbols at the top level?
# ======
# magic_imports.py
# this is just an example but there could be 20 different classes here
# the purpose is to import all the symbols so any file that uses them doesn't have to deal with the full path
from long.stupid.path import Glorp as _Glorp
from long.other.stupid.path import Blarg as _Blarg
(env) llamaforge:opsmop michaeldehaan$ python bin/opsmop apply demo/conditionals.py
-----------------
1. File: /tmp/foo1.txt (signals: file1changed)
actions planned: (['chmod'])
result: ok
signals: file1changed
-----------------
2. File: /tmp/foo2.txt (signals: file2changed)
executing: (sha1sum /tmp/foo2.txt)
# I don't know about this?
# most people should prefer the Python DSL
# but what if some teams don't want to learn Python?
# here's an OPTIONAL idea for a new capability
# ==================
class FooRole(Foo):
def set_bundles(self):
@mpdehaan
mpdehaan / opsmop_cla
Created December 4, 2018 12:28
opsmop CLA
BACKGROUND
Thank you very much for your interest in contributing to Vespene. The purpose of the OpsMop community is work together to create great software we can all share and use.
Vespene is licensed under the Apache 2.0 Software License.
AGREEMENT
By contributing your code to OpsMop you grant the Michael DeHaan LLC a non-exclusive, irrevocable, worldwide, royalty-free, sublicenseable, transferable license under all of Your relevant intellectual property rights (including copyright, patent, and any other rights), to use, copy, prepare derivative works of, distribute and publicly perform and display the Contributions on licensing terms of the current license.
@mpdehaan
mpdehaan / gist:ee37df93e988072b0fa53dbff5fb98ed
Created December 10, 2018 17:58
Possible fanout syntax
[groups.bastions.hosts]
"bastion.example.com" = ""
[groups.rack1.hosts]
"rack1-top.example.com" = "opsmop_via=bastion.example.com"
"rack1-101.example.com" = ""
"rack1-102.example.com" = ""
[groups.rack2.hosts]
"rack2-top.example.com" = "opsmop_via=bastion.example.com"
_build_tuple('markupsafe._speedups'): could not locate source
ModuleResponder(Router(Broker(0x10340e860))): refusing to serve stdlib module 'pathlib'
Message(0, 1, 1, 1001, 0, b'\x80\x02cmitogen.core\n_unpickle_call_error\nq\x01X\xe6\x06\x00\x00except'..1817)
Traceback (most recent call last):
File "push_demo.py", line 55, in <module>
Cli(Demo())
File "/Users/michaeldehaan/Devel/opsmop/opsmop/client/cli.py", line 47, in __init__
self.go()
File "/Users/michaeldehaan/Devel/opsmop/opsmop/client/cli.py", line 103, in go
api.apply()
# BEFORE
class FooRole(Role):
def set_variables(self):
return dict(
x=5
)
def set_resources(self):
# push mode will look about like this:
if __name__ == '__main__':
inventory = TomlInventory("inventory/inventory.toml")
inventory.ssh([WebServerRole(), AnotherRole() ])
# if you want to run check mode, you can still access it, though it is not the default:
inventory.ssh([WebServers(), AnotherRole() ], check=True)