Skip to content

Instantly share code, notes, and snippets.

@nicholaskuechler
nicholaskuechler / gist:6827654
Created October 4, 2013 15:17
Ansible - run command on a single host (10.20.30.40)
#!/usr/bin/python
import ansible.runner
import sys
# construct the ansible runner and execute on all hosts
results = ansible.runner.Runner(
host_list=['10.20.30.40'],
pattern='*',
forks=10,
# my virtualenvs are in ~/virtualenvs - you may need to adjust for your environment
cd ~/virtualenvs
virtualenv pelican-sprint-test
cd pelican-sprint-test
. bin/activate
mkdir ~/virtualenvs/pelican-sprint-test/src
cd ~/virtualenvs/pelican-sprint-test/src
git clone https://github.com/getpelican/pelican
cd pelican
pip install -r dev_requirements.txt
[customerlon]
NOVA_URL=https://lon.identity.api.rackspacecloud.com/v2.0/
NOVA_VERSION=1.1
NOVA_RAX_AUTH=1
NOVA_SERVICE_NAME=cloudServersOpenStack
NOVA_USERNAME=Username_here
NOVA_PASSWORD=API_key_here
NOVA_PROJECT_ID=DDI_number_here
NOVA_REGION_NAME=LON
@nicholaskuechler
nicholaskuechler / gist:3353575
Created August 14, 2012 22:31
slicehost - add a new zone via api with ruby
require 'activeresource'
API_PASSWORD = 'API_KEY_HERE'
class Zone < ActiveResource::Base
self.site = "https://#{API_PASSWORD}@api.slicehost.com/"
end
zone = Zone.new(:origin => 'myexample483727329784397.com', :ttl => 3000)
zone.save
@nicholaskuechler
nicholaskuechler / gist:3353553
Created August 14, 2012 22:27
slicehost - add a new zone via api with python
from pyactiveresource.activeresource import ActiveResource
api_password = 'API_KEY_HERE'
api_site = 'https://%s@api.slicehost.com/' % api_password
class Slice(ActiveResource):
_site = api_site
class Zone(ActiveResource):
_site = api_site
@nicholaskuechler
nicholaskuechler / slicehost_list_bandwidth.py
Created July 24, 2012 15:29
Slicehost - list slice bandwidth in / bandwidth out
from pyactiveresource.activeresource import ActiveResource
api_password = 'YOUR_API_KEY_GOES_HERE'
api_site = 'https://%s@api.slicehost.com/' % api_password
class Slice(ActiveResource):
_site = api_site
class Zone(ActiveResource):
_site = api_site
@nicholaskuechler
nicholaskuechler / gist:3091886
Created July 11, 2012 17:29
rackspace cloudservers - list host machines a cloud server is running on
"""
list cloud servers and their physical host
"""
import cloudservers
USERNAME = "your_username_here"
API_KEY = "your_api_key_here"
cloudservers = cloudservers.CloudServers(USERNAME, API_KEY)
<VirtualHost *:80>
Servername yourdomain.com
ServerAlias www.yourdomain.com
Redirect permanent / http://www.facebook.com/yourUsernameOrWhatever
</VirtualHost>
@nicholaskuechler
nicholaskuechler / gist:72ae99ef1acc85a712fe
Created January 9, 2015 02:29
ansible playbook output - create rackspace cloud server, add dns entries, and install packages using roles
(rackspace)nick@mbp: ~/ansible-rackspace-servers$ ansible-playbook -i venv-inventory.yml build-cloud-server.yml
PLAY [Create a Rackspace Cloud Server] ****************************************
TASK: [Rackspace cloud server build request] **********************************
ok: [localhost -> 127.0.0.1]
TASK: [Add new cloud server to host group] ************************************
ok: [localhost -> 127.0.0.1] => (item={u'status': u'ACTIVE', u'rax_name': u'admin.enhancedtest.net', u'rax_metadata': {}, u'rax_progress': 100, u'rax_os-dcf_diskconfig': u'MANUAL', u'rax_human_id': u'adminenhancedtestnet', u'rax_addresses': {u'public': [{u'version': 6, u'addr': u'2001:4800:7818:104:be76:4eff:fe05:3c58'}, {u'version': 4, u'addr': u'104.130.158.89'}], u'private': [{u'version': 4, u'addr': u'10.209.36.188'}]}, u'rax_image': {u'id': u'0766e5df-d60a-4100-ae8c-07f27ec0148f', u'links': [{u'href': u'https://dfw.servers.api.rackspacecloud.com/HIDDEN/images/0766e5df-d60a-4100-ae8c-07f27ec0148f', u'rel': u'bookmark'}]}, u'rax_
@nicholaskuechler
nicholaskuechler / gist:d2562ef1c780cdeffe14
Created January 9, 2015 02:23
ansible playbook output - create cloud server and add dns entries - second run
PLAY [Create a Rackspace Cloud Server] ****************************************
TASK: [Rackspace cloud server build request] **********************************
ok: [localhost -> 127.0.0.1]
TASK: [Add new cloud server to host group] ************************************
ok: [localhost -> 127.0.0.1] => (item={u'status': u'ACTIVE', u'rax_name': u'admin.enhancedtest.net', u'rax_metadata': {}, u'rax_progress': 100, u'rax_os-dcf_diskconfig': u'MANUAL', u'rax_human_id': u'adminenhancedtestnet', u'rax_addresses': {u'public': [{u'version': 6, u'addr': u'2001:4800:7818:104:be76:4eff:fe05:3c58'}, {u'version': 4, u'addr': u'104.130.158.89'}], u'private': [{u'version': 4, u'addr': u'10.209.36.188'}]}, u'rax_image': {u'id': u'0766e5df-d60a-4100-ae8c-07f27ec0148f', u'links': [{u'href': u'https://dfw.servers.api.rackspacecloud.com/HIDDEN/images/0766e5df-d60a-4100-ae8c-07f27ec0148f', u'rel': u'bookmark'}]}, u'rax_user_id': u'HIDDEN', u'rax_links': [{u'href': u'https://dfw.servers.api.rackspacecloud.com/v2/HIDDEN/servers/0221