def _run_deploy(dest, sudo=False, ask_sudo_pass=False): prepare_source_package() ansible = ensure_ansible() click.echo(click.style("Running deployment on {0!r}. This may take a while...".format(dest), fg='magenta')) if dest == "vagrant": # Vagrant will invoke ansible environ = os.environ.copy() environ["PATH"] = "{}:{}".format(os.path.dirname(ansible), environ["PATH"]) # "vagrant up --provision" doesn't call provision if the virtual machine is already up, # so we have to call vagrant provision explicitly subprocess.check_call('vagrant up', shell=True, env=environ) subprocess.check_call('vagrant provision', shell=True, env=environ) else: cmd = [ansible, "-i", from_project_root("ansible", "inventories", dest)] if dest in ("localhost",): cmd.extend(["-c", "local"]) if dest == "localhost": cmd.append("--sudo") if sudo: cmd.append('--sudo') if ask_sudo_pass: cmd.append('--ask-sudo-pass') cmd.append(from_project_root("ansible", "site.yml")) subprocess.check_call(cmd)
def deploy(dest, sudo, ask_sudo_pass, vagrant_machine, inventory): prepare_source_package() ansible = ensure_ansible() if dest == "vagrant": # Vagrant will invoke ansible environ = os.environ.copy() environ["PATH"] = "{}:{}".format(os.path.dirname(ansible), environ["PATH"]) # "vagrant up --provision" doesn't call provision if the virtual machine is already up, # so we have to call vagrant provision explicitly click.echo( click.style( "Running deployment on Vagrant. This may take a while...", fg='magenta')) subprocess.check_call('vagrant up ' + vagrant_machine, shell=True, env=environ) subprocess.check_call('vagrant provision ' + vagrant_machine, shell=True, env=environ) else: if dest == "custom": if inventory is None: raise click.ClickException( "-i/--inventory should be specified together with \"--dest custom\"" ) if not os.path.exists(inventory): raise click.ClickException( "Custom inventory file {} doesn't exist".format(inventory)) else: if inventory is not None: raise click.ClickException( "-i/--inventory should be specified only when \"--dest custom\" is specified" ) inventory = from_project_root("ansible", "inventories", dest) click.echo( click.style( "Running deployment on {}. This may take a while...".format( inventory), fg='magenta')) cmd = [ansible, "-i", inventory] if dest in ("localhost", ): cmd.extend(["-c", "local"]) if dest == "localhost": cmd.append("--sudo") if sudo: cmd.append('--sudo') if ask_sudo_pass: cmd.append('--ask-sudo-pass') cmd.append(from_project_root("ansible", "site.yml")) subprocess.check_call(cmd)
def _run_deploy(dest): prepare_source_package() cmd = [from_env_bin("python"), from_env_bin("ansible-playbook"), "-i"] click.echo(click.style( "Running deployment on {0!r}. This may take a while...".format(dest), fg='magenta')) cmd.append(from_project_root("ansible", "inventories", dest)) if dest in ("localhost",): cmd.extend(["-c", "local"]) if dest == "localhost": cmd.append("--sudo") cmd.append(from_project_root("ansible", "site.yml")) if dest == "vagrant": subprocess.check_call('vagrant up', shell=True) os.environ["ANSIBLE_HOST_KEY_CHECKING"] = 'false' subprocess.check_call(cmd)
def _run_deploy(dest): prepare_source_package() ansible = ensure_ansible() click.echo(click.style("Running deployment on {0!r}. This may take a while...".format(dest), fg='magenta')) if dest == "vagrant": # Vagrant will invoke ansible environ = os.environ.copy() environ["PATH"] = "{}:{}".format(os.path.dirname(ansible), environ["PATH"]) subprocess.check_call('vagrant up', shell=True, env=environ) else: cmd = [ansible, "-i", from_project_root("ansible", "inventories", dest)] if dest in ("localhost",): cmd.extend(["-c", "local"]) if dest == "localhost": cmd.append("--sudo") cmd.append(from_project_root("ansible", "site.yml")) subprocess.check_call(cmd)
def deploy(dest, sudo, ask_sudo_pass, vagrant_machine, inventory): prepare_source_package() ansible = ensure_ansible() if dest == "vagrant": # Vagrant will invoke ansible environ = os.environ.copy() environ["PATH"] = "{}:{}".format(os.path.dirname(ansible), environ["PATH"]) # "vagrant up --provision" doesn't call provision if the virtual machine is already up, # so we have to call vagrant provision explicitly click.echo(click.style("Running deployment on Vagrant. This may take a while...", fg='magenta')) subprocess.check_call('vagrant up ' + vagrant_machine, shell=True, env=environ) subprocess.check_call('vagrant provision ' + vagrant_machine, shell=True, env=environ) else: if dest == "custom": if inventory is None: raise click.ClickException("-i/--inventory should be specified together with \"--dest custom\"") if not os.path.exists(inventory): raise click.ClickException("Custom inventory file {} doesn't exist".format(inventory)) else: if inventory is not None: raise click.ClickException("-i/--inventory should be specified only when \"--dest custom\" is specified") inventory = from_project_root("ansible", "inventories", dest) click.echo(click.style("Running deployment on {}. This may take a while...".format(inventory), fg='magenta')) cmd = [ansible, "-i", inventory] if dest in ("localhost",): cmd.extend(["-c", "local"]) if dest == "localhost": cmd.append("--sudo") if sudo: cmd.append('--sudo') if ask_sudo_pass: cmd.append('--ask-sudo-pass') cmd.append(from_project_root("ansible", "site.yml")) subprocess.check_call(cmd)
def _run_deploy(dest, sudo=False, ask_sudo_pass=False): prepare_source_package() ansible = ensure_ansible() click.echo( click.style( "Running deployment on {0!r}. This may take a while...".format( dest), fg='magenta')) if dest == "vagrant": # Vagrant will invoke ansible environ = os.environ.copy() environ["PATH"] = "{}:{}".format(os.path.dirname(ansible), environ["PATH"]) # "vagrant up --provision" doesn't call provision if the virtual machine is already up, # so we have to call vagrant provision explicitly subprocess.check_call('vagrant up', shell=True, env=environ) subprocess.check_call('vagrant provision', shell=True, env=environ) else: cmd = [ ansible, "-i", from_project_root("ansible", "inventories", dest) ] if dest in ("localhost", ): cmd.extend(["-c", "local"]) if dest == "localhost": cmd.append("--sudo") if sudo: cmd.append('--sudo') if ask_sudo_pass: cmd.append('--ask-sudo-pass') cmd.append(from_project_root("ansible", "site.yml")) subprocess.check_call(cmd)
def _run_docker_build(): prepare_source_package() build_docker_image(tag=APP_NAME, root=from_project_root())