Skip to content

Instantly share code, notes, and snippets.

import subprocess
def lambda_handler(event, context):
print(
subprocess.check_output(
'whereis ssh',
shell=True
)
)
import sys
def lambda_handler(event, context):
print(
' '.join(sys.modules.keys())
)
# heapq code functools random wsgi sysconfig logging.os
# encodings.encodings logging.weakref tempfile base64
# _json imp collections logging.thread wsgiref.os zipimport
@jacoelho
jacoelho / ansible_lambda.py
Last active July 19, 2019 01:03
ansible lambda
#!/usr/bin/python
import ansible.inventory
import ansible.playbook
import ansible.runner
from ansible import utils
from ansible import callbacks
def run_playbook(**kwargs):
- hosts: all
connection: local
tasks:
- shell: echo test
#!/usr/bin/python
import ansible.inventory
import ansible.playbook
import ansible.runner
import ansible.constants
from ansible import utils
from ansible import callbacks
def run_playbook(**kwargs):
import json
import boto3
def lambda_handler(event, context):
client = boto3.client('sns', region_name='us-west-2')
response = client.publish(
TopicArn='arn:aws:sns:us-west-2:XXXXXXX:ansible-api',
Message=json.dumps(event),
{
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*"
#!/usr/bin/python
import json
import ansible.inventory
import ansible.playbook
import ansible.runner
import ansible.constants
from ansible import utils
from ansible import callbacks
- hosts: localhost
become: yes
connection: local
tasks:
- apt_key:
keyserver: keyserver.ubuntu.com
id: 642AC823
- apt_repository:
@jacoelho
jacoelho / scala.yml
Last active July 3, 2016 21:17
install scala ansible 2.1
- hosts: localhost
become: yes
connection: local
tasks:
- apt_key:
keyserver: keyserver.ubuntu.com
id: 642AC823
- apt_repository: