Last active
August 29, 2015 14:01
-
-
Save iamjohnnym/4de6fca327688f9de15b to your computer and use it in GitHub Desktop.
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
# LAMP Deployment Vars | |
# group_vars/all | |
playbook: { | |
'php5': { | |
'apache': "apache2", | |
'packages': [ | |
"libapache2-mod-php5", | |
"php5-cli", | |
"php-pear", | |
"php5-mysql", | |
"php-apc", | |
"php5-gd", | |
"php5-dev", | |
"php5-curl" | |
], | |
'php_ini': "/etc/php5/apache2/php.ini", | |
'session': { | |
'save_path': "/var/lib/php5/session" | |
} | |
} | |
} | |
############### | |
# part of roles/php5/main.yml | |
- name: Install PHP and packages | |
apt: pkg={{item}} state=installed update_cache=true | |
with_items: playbook.php5.packages | |
when: ansible_os_family == 'Debian' | |
############### | |
site.yml | |
--- | |
- hosts: localhost | |
user: root | |
roles: | |
- php5 | |
############## | |
#sample script for deploying ansible programmically | |
#!venv/bin/python | |
from ansible import utils | |
from ansible.callbacks import AggregateStats, PlaybookCallbacks, PlaybookRunnerCallbacks | |
from ansible.runner import Runner | |
import sys | |
class SSL(): | |
def __init__(self, common_name, alt_names, organization, | |
organizational_unit, locality, region, country, email): | |
self.common_name = common_name | |
self.alt_names = alt_names | |
self.organization = organization | |
self.organizational_unit = organizational_unit | |
self.email = email | |
self.locality = locality | |
self.region = region | |
self.country = country | |
self.stats = AggregateStats() | |
self.playbook_cb = PlaybookCallbacks(verbose=utils.VERBOSITY) | |
self.runner_cb = PlaybookRunnerCallbacks(self.stats, verbose=utils.VERBOSITY) | |
def run(self): | |
results = Runner( | |
forks=10, | |
private_key_file='/Users/john6301/.ssh/id_rsa', | |
remote_user='root', | |
inventory='/Users/john6301/projects/jane/inventory', | |
callbacks=self.playbook_cb, | |
runner_callbacks=self.runner_cb, | |
stats=self.stats | |
).run() | |
return results | |
if __name__ == '__main__': | |
ssl = SSL(common_name='foo.com', | |
alt_names='www.foo.com', | |
organization='Foo Inc', | |
organizational_unit='RABUF', | |
email='bar@foo.com', | |
region='TX', | |
country='US', | |
locality='San Antonio' | |
).run() | |
print ssl | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment