This file contains 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
## usage lookup('template_url', 'https://myserver/template.j2') | |
import urllib2 | |
import tempfile | |
import os | |
from ansible import utils | |
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError | |
from ansible.utils.unicode import to_unicode | |
from glob import glob |
This file contains 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
## DISA STIG For RHEL6 Revision 8 Version 1 | |
- name: Category 1 Results | |
rule_results: | |
- vuln_id: V-38476 | |
rule_id: SV-50276r3_rule | |
stig_id: RHEL-06-00000 | |
rule_title: Vendor-provided cryptographic certificates must be installed to verify the integrity of system software. | |
result: FAIL |
This file contains 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
#!/usr/bin/python | |
import urllib | |
import os | |
GH_URL = 'https://raw.githubusercontent.com/jsmartin/lightbulb/master/lessons/common_role/roles/apache/templates/index.html.j2' | |
def download(module, url, destination): | |
opener = urllib.URLopener() | |
opener.retrieve(url, destination) |
This file contains 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 LookupModule(object): | |
def __init__(self, basedir=None, **kwargs): | |
self.basedir = basedir | |
def run(self, terms, inject=None, **kwargs): | |
if isinstance(terms, basestring): | |
terms = [ terms ] | |
ret = [] |
This file contains 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
from jinja2 import contextfilter | |
class FilterModule(object): | |
''' Extra filters ''' | |
def filters(self): | |
return { | |
'nameoffilter': self.name_of_method, | |
} |
This file contains 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 os | |
def main(): | |
module = AnsibleModule( | |
argument_spec = dict( | |
state = dict(required=True, choices=['present', 'absent']), | |
name = dict(required=True), | |
content = dict(required=True) | |
), |
This file contains 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
- name: Move original key | |
command: mv files/sshkeys/{{item.value.username}}.priv files/sshkeys/{{item.value.username}}.priv.last | |
args: | |
removes: files/sshkeys/{{item.value.username}}.priv | |
delegate_to: localhost | |
with_dict: autologic_system_users | |
run_once: yes | |
when: rotate | |
- name: Move old pub key |
This file contains 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
#!/usr/bin/python | |
# libraries you import here, must be present on the target node. | |
import os | |
# You can defined other functions up here to make your code more modular. | |
# These functions will need to be called from main(), either directly or through N number of other functions | |
# that eventually lead back to main() | |
def main(): |
This file contains 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
from jinja2 import contextfilter | |
class FilterModule(object): | |
''' Extra filters ''' | |
def filters(self): | |
return { | |
'reverse': self.reverse_string, | |
} |
This file contains 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
#!/usr/bin/python | |
import hashlib | |
def main(): | |
module = AnsibleModule( | |
argument_spec = dict( | |
string = dict(required=True) | |
), |