Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Add CF config to salt pillar.
Browse files Browse the repository at this point in the history
This uploads the stack config to cloudformtaion.sls in the salt
pillar dir. This way it can be included in the pillar in the deploy
repositories and referenced in the salt templates.
  • Loading branch information
mattmb committed Mar 24, 2015
1 parent e913f02 commit 79dff7e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions bootstrap_cfn/fab_tasks.py
Expand Up @@ -2,14 +2,16 @@

import sys
import random
import yaml
from bootstrap_cfn.config import AWSConfig, ProjectConfig, ConfigParser
from bootstrap_cfn.cloudformation import Cloudformation
from bootstrap_cfn.ec2 import EC2
from bootstrap_cfn.iam import IAM

import os
from StringIO import StringIO

from fabric.api import env, task, sudo
from fabric.api import env, task, sudo, put
from fabric.contrib.project import upload_project

# GLOBAL VARIABLES
Expand Down Expand Up @@ -96,13 +98,11 @@ def get_config():
cfn_config = ConfigParser(project_config.config, get_stack_name())
return cfn_config


def get_connection(klass):
_validate_fabric_env()
aws_config = AWSConfig(env.aws)
return klass(aws_config)


@task
def cfn_delete(force=False):
if not force:
Expand Down Expand Up @@ -261,6 +261,7 @@ def rsync():
work_dir = os.path.join('..', '{0}-deploy'.format(env.application))

project_config = ProjectConfig(env.config, env.environment)
stack_name = get_stack_name()
cfg = project_config.config
salt_cfg = cfg.get('salt', {})

Expand Down Expand Up @@ -300,3 +301,10 @@ def rsync():
remote_dir=remote_pillar_dir,
local_dir=os.path.join(local_pillar_dir, env.environment, '.'),
use_sudo=True)
cf_sls = StringIO(yaml.dump(cfg))
put(
remote_path=os.path.join(
remote_pillar_dir,
'cloudformation.sls'),
local_path=cf_sls,
use_sudo=True)

0 comments on commit 79dff7e

Please sign in to comment.