This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import socket) | |
(import [collections [namedtuple]]) | |
(setv bindparams (namedtuple "bindparams" ["host" "port"])) | |
(setv bp (bindparams "" 8888)) | |
(setv listen_socket (socket.socket socket.AF_INET socket.SOCK_STREAM)) | |
(listen_socket.setsockopt socket.SOL_SOCKET socket.SO_REUSEADDR 1) | |
(listen_socket.bind bp) | |
(listen_socket.listen 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tempfile, os, subprocess | |
if not 'DO_API_TOKEN' in os.environ: | |
print("DigitalOcean API token not found. Export DO_API_TOKEN.") | |
exit(1) | |
with tempfile.NamedTemporaryFile() as fp: | |
fp.write("localhost ansible_connection=local") | |
invocation = "ansible localhost -i {tmpfile} -m digital_ocean -a".format(tmpfile=fp.name).split(' ') | |
invocation.append('command=ssh list_keys=true') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLAY [create vpn server] ****************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [localhost] | |
TASK: [create-droplet | ensure dopy is installed (for digitalocean API)] ****** | |
ok: [localhost] | |
TASK: [create-droplet | create digitalocean droplet] ************************** | |
ok: [localhost] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLAY [create vpn server] ****************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [localhost] | |
TASK: [create-droplet | ensure dopy is installed (for digitalocean API)] ****** | |
ok: [localhost] | |
TASK: [create-droplet | create digitalocean droplet] ************************** | |
ok: [localhost] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
joe@nor ~/ansible-digitalocean-vpn $ ./create-vpn | |
PLAY [create vpn server] ****************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [localhost] | |
TASK: [create-droplet | ensure dopy is installed (for digitalocean API)] ****** | |
ok: [localhost] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLAY [create vpn server] ****************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [localhost] | |
TASK: [create-droplet | ensure dopy is installed (for digitalocean API)] ****** | |
ok: [localhost] | |
TASK: [create-droplet | create digitalocean droplet] ************************** | |
ok: [localhost] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLAY [create vpn server] ****************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [localhost] | |
TASK: [create-droplet | ensure dopy is installed (for digitalocean API)] ****** | |
ok: [localhost] | |
TASK: [create-droplet | create digitalocean droplet] ************************** | |
ok: [localhost] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLAY [create vpn server] ****************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [localhost] | |
TASK: [create-droplet | ensure dopy is installed (for digitalocean API)] ****** | |
ok: [localhost] | |
TASK: [create-droplet | create digitalocean droplet] ************************** | |
ok: [localhost] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Adapter: | |
def __init__(self, object, **adapted_method): | |
self.object = object | |
self.__dict__.update(adapted_method) | |
def __getattr__(self, attr): | |
return getattr(self.object, attr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
supervisord [supervisord.org] | |
============================= | |
* Set up jobs via a config file (.ini style) | |
Example: | |
-------- | |
[program:forever] | |
command=/usr/bin/python /root/supervisoreval/bin/forever.py & | |
numprocs=1 |