Address comments to lxc branch and fix several bugs with example-lxc.py

- C.HOST_KEY_CHECKING = False for ansible_playbook.py handler
- mkdir -p {{keys_dir}} added to ssh_key resource run action
This commit is contained in:
Dmitry Shulyak 2015-09-03 12:30:37 +03:00
parent 276f58fb4f
commit e879c07d4b
5 changed files with 24 additions and 21 deletions

View File

@ -42,8 +42,9 @@ def deploy():
seed = vr.create('nodes', 'templates/seed_node.yml', {})[0]
ssh_key = vr.create('ssh_key1', 'resources/ssh_key', {
'path': '/vagrant/.ssh/id_rsa',
'pub_path': '/vagrant/.ssh/id_rsa.pub',
'keys_dir': '/vagrant/.ssh',
'private_key': '/vagrant/.ssh/id_rsa',
'public_key': '/vagrant/.ssh/id_rsa.pub',
'passphrase': '',
})[0]
signals.connect(seed, ssh_key)
@ -100,8 +101,8 @@ def deploy():
signals.connect(lxc_infra1, lxc_host_idx, {'provides': 'requires'})
signals.connect(cnets2, lxc_host_idx)
signals.connect(ssh_key, lxc_host_idx, {
'pub_path': 'pub_key',
'path': 'user_key'})
'public_key': 'pub_key',
'private_key': 'user_key'})
# RABBIT
rabbitmq_service1 = vr.create('rabbitmq_service1', 'resources/rabbitmq_service/', {
@ -134,5 +135,3 @@ main.add_command(deploy)
if __name__ == '__main__':
main()
ansible-playbook --module-path /vagrant/library -i /tmp/tmp8bTQzi/tmpGUYX4Bdocker20/inventory /tmp/tmp8bTQzi/tmpGUYX4Bdocker20/runIMUDej

View File

@ -3,10 +3,12 @@
gather_facts: false
# this is default variables, they will be overwritten by resource one
vars:
path: /vagrant/.ssh/id_rsa
keys_dir: /vagrant/.ssh
private_key: /vagrant/.ssh/id_rsa
passphrase: ''
tasks:
- stat: path={{path}}
- shell: mkdir -p {{keys_dir}}
- stat: path={{private_key}}
register: key
- shell: ssh-keygen -t rsa -f {{path}} -N ""
- shell: ssh-keygen -t rsa -f {{private_key}} -N ""
when: key.stat.exists == False

View File

@ -12,10 +12,13 @@ input:
ssh_user:
schema: str!
value:
path:
keys_dir:
schema: str!
value:
pub_path:
private_key:
schema: str!
value:
public_key:
schema: str!
value:
passphrase:

View File

@ -21,12 +21,11 @@ class AnsiblePlaybook(base.BaseHandler):
def download_roles(self, urls):
if not os.path.exists(ROLES_PATH):
os.makedirs(ROLES_PATH)
for url in urls:
provider = SVNProvider(url)
provider.run()
fabric_api.local('cp -r {} {}'.format(
provider.repo_directory, ROLES_PATH))
provider.directory, ROLES_PATH))
def action(self, resource, action):
action_file = os.path.join(
@ -48,7 +47,7 @@ class AnsiblePlaybook(base.BaseHandler):
else:
host = 'localhost'
transport = 'local'
C.HOST_KEY_CHECKING = False
play = PlayBook(
playbook=action_file,
remote_user=remote_user,

View File

@ -115,17 +115,17 @@ class SVNProvider(BaseProvider):
self.path = path
self.base_path = base_path or utils.read_config()['resources-directory']
if path != '.':
self.directory = os.path.join(self.base_path, path)
self.repo_directory = os.path.join(self.base_path, path)
else:
self.directory = self.base_path
self.repo_directory = os.path.join(self.directory, self.url.rsplit('/', 1)[-1])
self.repo_directory = self.base_path
self.directory = os.path.join(self.repo_directory, self.url.rsplit('/', 1)[-1])
def run(self):
if not os.path.exists(self.directory):
os.makedirs(self.directory)
if not os.path.exists(self.repo_directory):
os.makedirs(self.repo_directory)
if not os.path.exists(self.directory):
fabric_api.local(
'cd {dir} && svn checkout {url}'.format(
dir=self.directory,
dir=self.repo_directory,
url=self.url))