Skip to content

Override SUDO #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.kitchen
32 changes: 32 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---

driver :
name : docker
socket : unix:///var/run/docker.sock
use_sudo : false
volume : <%= File.dirname(__FILE__) %>:/avm

provisioner :
name : shell

platforms:
- name : "ubuntu1404"
driver_config :
platform : ubuntu
image : "ubuntu:14.04"
provision_command : curl -L https://www.opscode.com/chef/install.sh > /tmp/x.sh && sudo sh /tmp/x.sh -d /tmp;

- name : "ubuntu1604"
driver_config :
platform : ubuntu
image : "ubuntu:16.04"
provision_command : curl -L https://www.opscode.com/chef/install.sh > /tmp/x.sh && sudo sh /tmp/x.sh -d /tmp;

suites:
- name : simple
provisioner :
script : test/integration/simple/run_as_kitchen.sh

- name : advanced
provisioner :
script : test/integration/advanced/run_as_kitchen.sh
50 changes: 23 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
---
dist: trusty
language: ruby
rvm:
- 2.2
sudo: required
language: python
matrix:
allow_failures:
- os: osx
services:
- docker

os:
- linux
- osx
env:
- KITCHEN_TEST="simple-ubuntu1404"
- KITCHEN_TEST="simple-ubuntu1604"
- KITCHEN_TEST="advanced-ubuntu1404"
- KITCHEN_TEST="advanced-ubuntu1604"

before_install:
# Make sure everything's up to date.
- cd /tmp
- git clone https://github.com/sstephenson/bats.git
- cd /tmp/bats
- sudo ./install.sh /usr/local
- sudo apt-get update -qq
- sudo apt-get install -qq python-apt python-pycurl git python-pip ruby ruby-dev build-essential autoconf
- gem install bundler
# Get ansible install
- ruby --version
- python --version
- pip --version
- bundler --version

install:
- cd $TRAVIS_BUILD_DIR/example
- bash -x ./travis-setup-basic.sh
- bundle install

script:
- cd $TRAVIS_BUILD_DIR/tests
- ./common_test.sh
- ./ansible_version_test.sh
- ./various_runs_test.sh
# Run setup again with full path Basic
- bash -x $TRAVIS_BUILD_DIR/example/travis-setup-basic.sh
- ./installation_test.sh
- ansible --version
# Run setup again with full path setup user
- bash -x $TRAVIS_BUILD_DIR/example/travis-setup-user.sh
# Run tests for setup_user installation
- ./common_test.sh
- ./installation_setup_user_test.sh
- bundle exec kitchen test $KITCHEN_TEST

after_success:
- echo "Success"
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source 'https://rubygems.org'

group :development do
gem "test-kitchen"
gem 'kitchen-docker'
#gem 'net-ssh', '~> 3.0'
end
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# ansible-setup
[![Build Status](https://travis-ci.org/AutomationWithAnsible/ansible-setup.svg?branch=master)](https://travis-ci.org/AutomationWithAnsible/ansible-setup)

Setup mutli Ansible installation in python virtual env
# Ansible Version Manager (AVM)
[![Build Status](https://travis-ci.org/ahelal/avm.svg?branch=master)](https://travis-ci.org/ahelal/avm)

Ansible Version Manager (AVM) is a tool to manage mutli Ansible installation by creating a python virtual env for each version.

## Why
If you need to install multiple version of ansible and add python packages withouth effecting your global python installation.

- If you need to install multiple version of ansible and add python packages withouth effecting your global python installation.
- Running multi version on CI for testing i.e. travis
- Using the development version of ansible to test and using stable version for production

## how
Create a wrapper script like this one
```bash
#!/bin/bash
set -e

## This is an example setup script that you would encapsulate the installation
## This is an example setup script that you would encapsulate the installation

# What version of ansible setup to use
# What version of ansible setup to use
SETUP_VERSION="master"

# Whats my path
Expand All @@ -33,15 +35,15 @@ ANSIBLE_V1_PATH="${ANSIBLE_VERSIONS[0]}"
ANSIBLE_VERSIONS[1]="devel"
PYTHON_REQUIREMENTS[1]="$DIR/python_requirements.txt"
INSTALL_TYPE[1]="git"
# Make this the default for development
# Make this the default for development
ANSIBLE_DEV_PATH="${ANSIBLE_VERSIONS[1]}"

## 3. Install Ansible stable-2.0
## 3. Install Ansible stable-2.0
ANSIBLE_VERSIONS[2]="stable-2.0"
PYTHON_REQUIREMENTS[2]="$DIR/python_requirements.txt"
INSTALL_TYPE[2]="git"
# Make this default for v2
ANSIBLE_V2_PATH="${ANSIBLE_VERSIONS[2]}"
ANSIBLE_V2_PATH="${ANSIBLE_VERSIONS[2]}"

## 4. Install Ansible 1.9.3
ANSIBLE_VERSIONS[3]="stable-2.0"
Expand All @@ -66,7 +68,7 @@ exit 0
```

## Platforms
Currently supports Mac and ubuntu 14.04
Currently supports Mac and ubuntu 14.04, 16.04

## Options
You can basicly override any variable defined in [setup.sh](https://github.com/AutomationWithAnsible/ansible-setup/blob/master/setup.sh) in your script.
Expand Down
13 changes: 0 additions & 13 deletions ansible-version.yml

This file was deleted.

35 changes: 21 additions & 14 deletions ansible-version.j2 → avm.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ ANSIBLE_SELECTED_VERSION="{{ ANSIBLE_SELECTED_VERSION }}"

#Function: help
print_help() {
echo """$0
echo """avm
Usage:
$0 installed
$0 versions
$0 path <version>
$0 set <version>
avm info
avm list
avm path <version>
avm use <version>
avm activate [version]

Options:
installed Show available installed ansible virtualenv
versions Show current virtualenv version
info Show available installed ansible virtualenv
list List current virtualenv version
path <version> Print binary path of specifc version
set <version> Set selected version for ansible virtualenv
use <version> Use a <version> for ansible virtualenv
activate [version] Activate python in the ansible virtualenv
"""
exit 0
}
Expand All @@ -35,12 +37,13 @@ show_versions(){
do
[[ $version =~ ^(ansible-version)$ ]] && continue
[[ $version =~ ^(bin)$ ]] && continue
[[ $version =~ ^(avm)$ ]] && continue
versions_list+="'${version}' "
done
echo "$versions_list"
}

# Verify version
# Verify version
verify_version(){
versions_list="$(show_versions)"
if ! [[ ${versions_list} == *"'${ANSIBLE_SELECTED_VERSION}'"* ]]; then
Expand All @@ -62,18 +65,18 @@ print_path(){
setup_links(){
verify_version

for bin in ansible ansible-doc ansible-galaxy ansible-playbook ansible-pull ansible-vault
for bin in ansible ansible-doc ansible-galaxy ansible-playbook ansible-pull ansible-vault ansible-console
do
echo "Ensuring symlink $ANSIBLE_BASEDIR/${ANSIBLE_SELECTED_VERSION}/venv/bin/$bin :is pointing to ${ANSIBLE_BASEDIR}/bin/${bin}"
ln -sf $ANSIBLE_BASEDIR/${ANSIBLE_SELECTED_VERSION}/venv/bin/$bin ${ANSIBLE_BASEDIR}/bin/${bin}
done
}

case $1 in
"installed")
"info" | "installed")
show_installed
;;
"versions")
"list" | "versions")
echo "current installed version: $(show_versions)"
;;
"path")
Expand All @@ -82,12 +85,16 @@ case $1 in
export ANSIBLE_SELECTED_VERSION="$2"
print_path
;;
"set")
"use" | "set")
version="$2"
[ -z "$2" ] && echo "set requires a version as an argument." && exit 1
[ -z "$2" ] && echo "use requires a version as an argument." && exit 1
export ANSIBLE_SELECTED_VERSION="$2"
setup_links
;;
"activate" )
echo "WIP"
exit 1
;;
'')
print_help
;;
Expand Down
53 changes: 0 additions & 53 deletions example/example_setup.sh

This file was deleted.

14 changes: 0 additions & 14 deletions example/python_requirements.txt

This file was deleted.

35 changes: 0 additions & 35 deletions example/travis-install

This file was deleted.

Loading