소스 검색

Added external alfred-json role and added is dependency to ffmap-backend role

Till Klocke 9 년 전
부모
커밋
a0c60f3f94

+ 2 - 0
galaxy-roles/dereulenspiegel.alfred-json/.gitignore

@@ -0,0 +1,2 @@
+.kitchen/
+secrets

+ 32 - 0
galaxy-roles/dereulenspiegel.alfred-json/.kitchen.yml

@@ -0,0 +1,32 @@
+---
+driver:
+  name: vagrant
+
+provisioner:
+    name               : ansible_push
+    verbose            : "vvvv"
+    ansible_config     : "test/ansible.cfg"
+    idempotency_test   : False
+    sudo               : True
+    #chef_bootstrap_url : False
+    #extra_vars        : "@kitchen_vars.yml"
+
+platforms:
+    - name: Ubuntu-precise
+      driver:
+        box: ubuntu/precise64
+    - name: Debian-jessie
+      driver:
+        box: debian/jessie64
+    - name: Debian-wheezy
+      driver:
+        box: debian/wheezy64
+    - name: Ubuntu-trusty
+      driver:
+        box: ubuntu/trusty64
+
+suites:
+  - name: alfred-json
+    provisioner:
+      playbook: "test/application/alfred-json.yml"
+      extra_vars: {'kitchen_connection': 'smart'}

+ 23 - 0
galaxy-roles/dereulenspiegel.alfred-json/.travis.yml

@@ -0,0 +1,23 @@
+---
+language: python
+python: "2.7"
+
+before_install:
+  # Make sure everything's up to date.
+  - 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
+
+install:
+  - sudo pip install ansible
+
+
+script:
+    #- cd test
+    - ansible --version
+    - bundle install
+    - KITCHEN_YAML=.kitchen.travis.yml bundle exec kitchen test travis
+
+
+after_success:
+    - echo "Success"

+ 7 - 0
galaxy-roles/dereulenspiegel.alfred-json/Gemfile

@@ -0,0 +1,7 @@
+source "https://rubygems.org"
+
+gem "test-kitchen"
+gem "kitchen-ansiblepush"
+gem "kitchen-ansible"
+gem "kitchen-vagrant"
+gem "kitchen-localhost"

+ 47 - 0
galaxy-roles/dereulenspiegel.alfred-json/README.md

@@ -0,0 +1,47 @@
+alfred-json [![Build Status](https://travis-ci.org/dereulenspiegel/ansible-alfred-json.svg)](https://travis-ci.org/dereulenspiegel/ansible-alfred-json)
+=========
+
+This role simply compiles and installs [alfred-json](https://github.com/tcatm/alfred-json).
+
+Requirements
+------------
+
+None, except ansible and a Debian based host.
+
+Role Variables
+--------------
+
+## Default Variables
+
+None of these need to be modified, but is is possible to modify them to suit your needs (i.e. build your custom fork)
+
+Name | Default | Description
+---- | ------- | -----------
+alfred_json_repo_url | https://github.com/tcatm/alfred-json.git | The git url to clone alfred-json from
+alfred_json_version | v0.3.1 | Branch or tag to checkout after cloning
+alfred_json_src_dir | /usr/src/alfred-json | Where to clone the sources
+alfred_json_build_dir | /usr/src/alfred-json-build | CMake build dir
+
+Dependencies
+------------
+
+None
+
+Example Playbook
+----------------
+
+Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
+
+    - hosts: servers
+      roles:
+         - { role: dereulenspiegel.alfred-json }
+
+License
+-------
+
+MIT
+
+Author Information
+------------------
+
+Till Klocke [dereulenspiegel](https://twitter.com/dereulenspiegel)

+ 6 - 0
galaxy-roles/dereulenspiegel.alfred-json/defaults/main.yml

@@ -0,0 +1,6 @@
+---
+# defaults file for alfred-json
+alfred_json_repo_url: https://github.com/tcatm/alfred-json.git
+alfred_json_version: v0.3.1
+alfred_json_src_dir: /usr/src/alfred-json
+alfred_json_build_dir: /usr/src/alfred-json-build

+ 2 - 0
galaxy-roles/dereulenspiegel.alfred-json/handlers/main.yml

@@ -0,0 +1,2 @@
+---
+# handlers file for alfred-json

+ 1 - 0
galaxy-roles/dereulenspiegel.alfred-json/meta/.galaxy_install_info

@@ -0,0 +1 @@
+{install_date: 'Fri Aug 14 17:53:38 2015', version: v1.0}

+ 18 - 0
galaxy-roles/dereulenspiegel.alfred-json/meta/main.yml

@@ -0,0 +1,18 @@
+---
+galaxy_info:
+  author: Till Klocke
+  description: Installs alfred-json
+  company: Freifunk Dortmund
+  license: MIT
+  min_ansible_version: 1.2
+  platforms:
+  - name: Ubuntu
+    versions:
+    - all
+  - name: Debian
+    versions:
+    - all
+  categories:
+  - monitoring
+  - networking
+dependencies: []

+ 27 - 0
galaxy-roles/dereulenspiegel.alfred-json/tasks/main.yml

@@ -0,0 +1,27 @@
+---
+# tasks file for alfred-json
+
+- include_vars: "{{ ansible_os_family }}.yml"
+
+- name: Install build dependencies
+  apt: name={{item}} state=present
+  with_items: "{{alfred_json_build_deps}}"
+
+- name: Create directories for clone and build
+  file: dest={{item}} state=directory
+  with_items:
+  - "{{alfred_json_src_dir}}"
+  - "{{alfred_json_build_dir}}"
+
+- name: Clone alfred-json repo
+  git: dest={{alfred_json_src_dir}} repo={{alfred_json_repo_url}} version={{alfred_json_version}}
+
+- name: Cmake alfred-json
+  shell: cmake {{alfred_json_src_dir}}
+  args:
+    chdir: "{{alfred_json_build_dir}}"
+
+- name: Build and install alfred-json
+  shell: make && make install
+  args:
+    chdir: "{{alfred_json_build_dir}}"

+ 2 - 0
galaxy-roles/dereulenspiegel.alfred-json/test/ansible.cfg

@@ -0,0 +1,2 @@
+[defaults]
+roles_path=../:../../:/spec/

+ 7 - 0
galaxy-roles/dereulenspiegel.alfred-json/test/application/alfred-json.yml

@@ -0,0 +1,7 @@
+---
+- name         : Install alfred-json from source
+  hosts        : all
+  gather_facts : yes
+  connection   : "{{ kitchen_connection | default('local') }}"
+  roles        :
+                 - "ansible-alfred-json"

+ 7 - 0
galaxy-roles/dereulenspiegel.alfred-json/test/application/alfred-json_travis.yml

@@ -0,0 +1,7 @@
+---
+- name         : Install alfde-json from source on Travis CI
+  hosts        : localhost
+  gather_facts : yes
+  connection   : "{{ kitchen_connection | default('local') }}"
+  roles        :
+                 - "ansible-alfred-json"

+ 10 - 0
galaxy-roles/dereulenspiegel.alfred-json/test/integration/alfred-json/serverspec/test_spec.rb

@@ -0,0 +1,10 @@
+require 'serverspec'
+
+# Required by serverspec
+set :backend, :exec
+
+describe file('/usr/local/bin/alfred-json') do
+  it { should be_file }
+  it { should be_readable }
+  it { should be_executable }
+end

+ 1 - 0
galaxy-roles/dereulenspiegel.alfred-json/test/local.ini

@@ -0,0 +1 @@
+localhost ansible_connection='local'

+ 17 - 0
galaxy-roles/dereulenspiegel.alfred-json/test/run_vagrant_kitchen.sh

@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+set -e
+echo "**** Box setup ***"
+
+echo "* mkdir /kitchen"
+mkdir -p /kitchen
+
+#echo "* cp -ar /mnt/shared /kitchen"
+#cp -r /mnt/shared/. /kitchen
+echo "* ln -sf /mnt/shared /kitchen"
+ln -sf /mnt/shared/* /kitchen/
+
+echo "* cd /kitchen"
+cd /kitchen/*
+
+echo "* python test/travis_run.py"
+python test/travis_run.py

+ 98 - 0
galaxy-roles/dereulenspiegel.alfred-json/test/travis_run.py

@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+# https://github.com/ahelal/travis-in-box
+
+import yaml
+import subprocess
+import sys
+import os.path
+
+
+class TravisExec(object):
+    def __init__(self, filename="travis.yml"):
+        self.fail = False
+        stream = open(filename, 'r')
+        yaml_file = yaml.load(stream)
+        # language
+        self.language = yaml_file.get("language", None)
+
+        # Section
+        self.section_before_install = yaml_file.get("before_install", None)
+        self.section_install = yaml_file.get("install", None)
+        self.section_before_script = yaml_file.get("before_script", None)
+        self.section_script = yaml_file.get("script", None)
+
+        #self.section_after_script = yaml_file.get("after_script", None)
+        self.section_after_failure = yaml_file.get("after_failure", None)
+        self.section_after_success = yaml_file.get("after_success", None)
+
+    def _setup(self):
+        if self.language == "python":
+            print "********** Setup Python  **********"
+            print ""
+            # Since we are not using container we have to install various lang our self
+            # So this is probably not the best way to do it
+            self._execute_command(["sudo apt-get install python-setuptools python-pip -y"])
+        else:
+            print "Errors unsupported language {}".format(self.language)
+            exit(1)
+
+    def life_cycle(self):
+        # See http://docs.travis-ci.com/user/build-configuration/
+
+            # 1. setup language
+            self._setup()
+            # 4. Run before_install commands
+            self.run_command("before_install", self.section_before_install, self.section_after_failure)
+            # 5. Run install commands
+            self.run_command("install", self.section_install, self.section_after_failure)
+            # 6. Run before_script commands
+            self.run_command("before_script", self.section_before_script, self.section_after_failure)
+            # 7. Run test script commands
+            self.run_command("script", self.section_script, self.section_after_failure)
+            # 8 . if we reach this point we made it run after_success
+            self.run_command("after_success", self.section_after_success, None)
+
+    @staticmethod
+    def _execute_command(command):
+        new_command = ["echo '> " + item.rstrip('\n') + "' && { " + item.rstrip('\n') + " ; }" for item in command]
+        new_command = " && ".join(new_command)
+
+        p = subprocess.Popen(new_command, shell=True, stderr=subprocess.PIPE)
+        while True:
+            out = p.stderr.read(1)
+            if out == '' and p.poll() is not None:
+                break
+            if out != '':
+                sys.stdout.write(out)
+                sys.stdout.flush()
+        print ""
+        return p.returncode
+
+    def run_command(self, section_name=None, command=None, execute_on_failure=None):
+        if command:
+            print ""
+            print "********** Running '{}' **********".format(section_name)
+            return_code = self._execute_command(command)
+            if return_code != 0:
+                print ""
+                print "********** Failed in '{}' **********".format(section_name)
+                if execute_on_failure:
+                    print ""
+                    print "********** Running after_failure  **********".format(section_name)
+                    self._execute_command(execute_on_failure)
+                    exit(1)
+
+filename = None
+if len(sys.argv) == 1:
+    filename = ".travis.yml"
+elif len(sys.argv) == 2:
+    filename = sys.argv[1]
+else:
+    print "Invalid number of arguments"
+    exit(1)
+
+if os.path.exists(filename):
+    TravisExec(filename).life_cycle()
+else:
+    print "Could not file travis file '{}'".format(filename)
+    exit(1)

+ 8 - 0
galaxy-roles/dereulenspiegel.alfred-json/vars/Debian.yml

@@ -0,0 +1,8 @@
+alfred_json_build_deps:
+- cmake
+- build-essential
+- git
+- libjansson-dev
+- libjansson4
+- zlib1g-dev
+- pkg-config

+ 2 - 0
galaxy-roles/dereulenspiegel.alfred-json/vars/main.yml

@@ -0,0 +1,2 @@
+---
+# vars file for alfred-json

+ 3 - 0
requirements.yml

@@ -18,6 +18,9 @@
 - src: dereulenspiegel.alfred
   path: galaxy-roles
 
+- src: dereulenspiegel.alfred-json
+  path: galaxy-roles
+
 - src: jdauphant.nginx
   path: galaxy-roles
 

+ 1 - 1
roles/ffmap-backend/meta/main.yml

@@ -14,4 +14,4 @@ galaxy_info:
   - networking
 dependencies:
 - dereulenspiegel.alfred
-- alfred-json
+- dereulenspiegel.alfred-json