Skip to content

jsmartin/tower_populator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

tower_populator

The purpose of this project is to populate an Ansible Tower installation from a configuration file.

Requirements

pip install ansible-tower-cli 

current version requires installation from tower-cli issue-9-unstable branch for dynamic group support

make sure you have ~/.tower_cli.cfg configured with something like:

host: 10.42.0.200
username: admin
password: password

Usage

Usage is simple. Declare the options you want in config.yml, and run the script:

./tower_populator config.yml

Creating Organization

Hyrule Ventures Mining Rupees Daily

Creating Users

{'username': 'link', 'is_superuser': True, 'first_name': 'Link', 'last_name': 'Smith', 'email': '[email protected]'}
{'username': 'gdorf', 'is_superuser': False, 'first_name': 'Gannon', 'last_name': 'Dorf', 'email': '[email protected]'}
{'username': 'zelda', 'is_superuser': False, 'first_name': 'Zelda', 'last_name': 'Smith', 'email': '[email protected]'}
{'username': 'epona', 'is_superuser': False, 'first_name': 'Epona', 'last_name': 'Horse', 'email': '[email protected]'}
{'username': 'demise', 'is_superuser': False, 'first_name': 'De', 'last_name': 'Mise', 'email': '[email protected]'}

Creating Teams

{'description': 'The Ops Team', 'users': ['link'], 'name': 'Ops'}
{'description': 'The QA Team', 'users': ['gdorf'], 'name': 'QA'}
{'description': 'The Dev Team', 'users': ['zelda'], 'name': 'Dev'}

Creating Credentials

{'username': 'vagrant', 'kind': 'ssh', 'name': 'Local SSH', 'team': 'Ops', 'private_key': '/root/vagrant-key', 'description': 'Used for non-cloud instances'}
{'username': 'myaccesskey', 'kind': 'aws', 'name': 'AWS creds', 'team': 'Ops', 'password': 'mysecretkey', 'description': 'Used for AWS'}
{'username': 'myusername', 'kind': 'rax', 'name': 'Rax Creds', 'team': 'Ops', 'password': 'myapikey', 'description': 'Used for Rackspace'}

Creating Inventories

{'name': 'Production', 'groups': [{'source': 'ec2', 'credential': 'AWS creds', 'description': 'EC2 hosts', 'name': 'EC2'}], 'description': 'Production Machines'}
{'name': 'Test', 'description': 'Test Machines'}
{'name': 'QA', 'description': 'QA Machines'}

Creating Projects

{'scm_type': 'git', 'name': 'Hyrulian Playbooks', 'scm_url': 'https://github.com/jsmartin/demo-cli', 'description': 'Configures all the servers in Hyrule.'}
{'scm_type': 'git', 'name': 'Ansible Examples', 'scm_url': 'https://github.com/ansible/ansible-examples', 'description': 'Some example roles and playbooks'}

Must sync projects from Tower UI if pulling from SCM.  Press any key after synch is finished.


Creating Job Templates

{'name': 'Apache', 'verbosity': 0, 'job_type': 'run', 'project': 'Hyrulian Playbooks', 'inventory': 'Production', 'forks': 7, 'machine_credential': 'Local SSH', 'playbook': 'apache.yml', 'description': 'Confgure Apache servers'}
{'name': 'Graphite', 'verbosity': 2, 'job_type': 'run', 'project': 'Hyrulian Playbooks', 'inventory': 'Production', 'machine_credential': 'Local SSH', 'playbook': 'graphite.yml', 'description': 'Confgure Graphite servers'}

Gotchas

tower-cli doesn't do everything the Tower UI does (yet), so there are some limitations:

  1. All credential types use username and password as options, even AWS, Rackspace, etc. This is a known issue.

About

Populate an Ansible Tower server from a configuration file.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages