This started as a way to handle some configuration and reporting needs.
Peter Sankauskas’ ec2.py module may let me back off from this path, except I need to manage some nodes under VMWare and Rackspace as well. I needed unified staging, reporting, and losts of hosts in multiple groups (painful to maintain in the current YAML). Downside is the hosts are specified in Python, making it smell like Infrastructure As Code, though I try not to drift into that.
Inventory.py (attached) works as a resource for ansible and also to give a brief inventory report. Stage selection is done with environment vars, which I drive with a script.
Hosts are separated into inventory/hosts.py. My plan is to not use any imperative python so non-programmers I report to can audit. Host’s py looks like this:
server( “00.00.00.00”,
“Current Collaboration Production Server”,
hostname=“collab.archive.org”,
stage=“prod”,
provider=“vmware”,
groups=[“sync_source”],
status=“will be moving to AWS”,
description=“”,
variables=dict(
),
)
server( “00.00.00.173”,
“Future Collaboration Production Server”,
hostname=“new.collab.archive.org”,
stage=“new”,
provider=“ec2”,
groups=[‘base’, ‘send_receive’, ‘nginx’, ‘web2py_uwsgi_2’, ‘extra_storage’, ‘sync_dest’],
status=“”,
description=“”,
variables={‘sr_revision’: ‘prod’, ‘w2p_password’: ‘hash_removed’}
)
server( “ec2-59-22-11-159.compute-1.amazonaws.com”,
“Collaboration Development Server”,
hostname=“dev.collab.archive.org”,
stage=“dev”,
provider=“ec2”,
groups=[‘base’, ‘send_receive’, ‘nginx’, ‘web2py_uwsgi_2’, ‘extra_storage’, ‘sync_dest’],
status=“testing”,
description=“”,
variables={‘sr_revision’: ‘prod’, ‘w2p_password’: ‘hash_removed’}
)
server( “ec2-50-22-22-108.compute-1.amazonaws.com”,
“Collaboration Quality-Assurance Server”,
hostname=“qa.collab.archive.org”,
stage=“qa”,
provider=“ec2”,
groups=[‘base’, ‘send_receive’, ‘nginx’, ‘web2py_uwsgi_2’, ‘extra_storage’, ‘sync_dest’],
status=“”,
description=“”,
variables={‘sr_revision’: ‘prod’, ‘w2p_password’: ‘hash_removed’}
)
(attachments)
inventory.py (4.93 KB)