Merge pull request #13477 from chrismeyersfsu/jenkins-playbooks

Jenkins playbooks
pull/13586/head
James Cammarata 9 years ago
commit 5fa93ef8fc

@ -55,3 +55,4 @@ Ansible was created by [Michael DeHaan](https://github.com/mpdehaan) (michael.de
Ansible is sponsored by [Ansible, Inc](http://ansible.com) Ansible is sponsored by [Ansible, Inc](http://ansible.com)

@ -0,0 +1,2 @@
[defaults]
host_key_checking = False

@ -0,0 +1,41 @@
- name: Launch Instance
ec2:
group_id: 'sg-07bb906d' # jenkins-slave_new
count: 1
instance_type: 'm3.medium'
image: '{{ item.image }}'
wait: true
region: 'us-east-1'
keypair: '{{ keypair }}'
aws_access_key: "{{ aws_access_key|default(lookup('env', 'AWS_ACCESS_KEY')) }}"
aws_secret_key: "{{ aws_secret_key|default(lookup('env', 'AWS_SECRET_KEY')) }}"
instance_tags:
jenkins: jenkins_ansible_pr_test
register: ec2
with_items: slaves
# We could do an async here, that would speed things up
- name: Wait for SSH
wait_for:
host: "{{ item['instances'][0]['public_ip'] }}"
port: 22
delay: 10
timeout: 320
state: started
with_items: ec2.results
- name: Wait a little longer for centos
pause: seconds=20
- name: Add hosts group temporary inventory group with pem path
add_host:
name: "{{ item.1.platform }} {{ ec2.results[item.0]['instances'][0]['public_ip'] }}"
groups: dynamic_hosts
ansible_ssh_host: "{{ ec2.results[item.0]['instances'][0]['public_ip'] }}"
ansible_ssh_private_key_file: '{{ pem_path }}'
ansible_ssh_user: "{{ item.1.ssh_user }}"
ec2_vars: "{{ ec2.results[item.0]['instances'][0] }}"
ec2_instance_ids: "{{ ec2.results[item.0]['instance_ids'] }}"
with_indexed_items: slaves

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

@ -0,0 +1,62 @@
- hosts: all
connection: local
vars:
slaves:
- distribution: "Ubuntu"
version: "12.04"
image: "ami-2ccc7a44"
ssh_user: "ubuntu"
platform: "ubuntu-12.04-x86_64"
- distribution: "Ubuntu"
version: "14.04"
image: "ami-9a562df2"
ssh_user: "ubuntu"
platform: "ubuntu-14.04-x86_64"
- distribution: "CentOS"
version: "6.5"
image: "ami-8997afe0"
ssh_user: "root"
platform: "centos-6.5-x86_64"
- distribution: "CentOS"
version: "7"
image: "ami-96a818fe"
ssh_user: "centos"
platform: "centos-7-x86_64"
tasks:
- debug: var=ansible_version
- include: ec2.yml
when: groups['dynamic_hosts'] is not defined
- hosts: dynamic_hosts
sudo: true
vars:
credentials_file: ''
test_flags: ""
make_target: "non_destructive"
#pre_tasks:
roles:
- { role: ansible_test_deps, tags: ansible_test_deps }
- { role: run_integration,
tags: run_integration,
run_integration_test_flags: "{{ test_flags }}",
run_integration_credentials_file: "{{ credentials_file }}",
run_integration_make_target: "{{ make_target }}", }
tasks:
- name: Kill ec2 instances
sudo: false
local_action:
module: ec2
state: absent
region: 'us-east-1'
instance_ids: "{{ hostvars[item]['ec2_instance_ids'] }}"
when: hostvars[item]['ec2_instance_ids'] is defined and item == inventory_hostname
with_items: groups['dynamic_hosts']
- set_fact:
ansible_connection: local
- name: Fail
shell: 'echo "{{ inventory_hostname }}, Failed" && exit 1'
when: "test_results.rc != 0"

@ -0,0 +1,37 @@
sudo: required
dist: trusty
language: python
python:
- "2.7"
services:
- docker
env:
global:
- PATH="/usr/bin:$PATH"
before_install:
# Ansible doesn't play well with virtualenv
- deactivate
- sudo apt-get update -qq
- sudo apt-get install docker-engine
install:
- sudo pip install docker-py
# software-properties-common for ubuntu 14.04
# python-software-properties for ubuntu 12.04
- sudo apt-get install -y sshpass software-properties-common python-software-properties
- sudo apt-add-repository -y ppa:ansible/ansible
- sudo apt-get update -qq
- sudo apt-get install -y ansible
- sudo rm /usr/bin/python && sudo ln -s /usr/bin/python2.7 /usr/bin/python
- ansible-galaxy install -r test/requirements.yml -p test/roles/
script:
# Ensure any invocation of ansible-playbook (i.e. sudo) results in host_key_checking disabled
- sudo ansible all -i "127.0.0.1," -m lineinfile -a "regexp=^#host_key_checking dest=/etc/ansible/ansible.cfg line='host_key_checking = False'" -c local
- ansible-playbook -i test/inventory test/main.yml --syntax-check
- sudo ansible-playbook -i test/inventory test/main.yml
notifications:
# notify ansible galaxy of results
webhooks: http://goo.gl/nSuq9h

@ -0,0 +1,6 @@
[![Build Status](https://travis-ci.org/chrismeyersfsu/ansible_test_deps.svg)](https://travis-ci.org/chrismeyersfsu/ansible_test_deps)
ansible_test_deps
=========
Install needed packages to run ansible integration tests.

@ -0,0 +1,23 @@
---
galaxy_info:
author: Chris Meyers
description: install ansible integration test dependencies
company: Ansible
license: license (GPLv2, CC-BY, etc)
min_ansible_version: 1.2
platforms:
- name: EL
versions:
- 6
- 7
- name: Ubuntu
versions:
- precise
- trusty
galaxy_tags:
- testing
- integration
- ansible
- dependencies
dependencies: []

@ -0,0 +1,81 @@
---
- name: Install sudo
yum: name=sudo state=installed
ignore_errors: true
when: ansible_os_family == 'RedHat'
- name: Install sudo
apt: name=sudo state=installed
ignore_errors: true
when: ansible_os_family == 'Debian'
- name: Install RH epel
yum: name="epel-release" state=installed
sudo: true
when: ansible_os_family == 'RedHat'
- name: Install RH ansible dependencies
yum: name="{{ item }}" state=installed
sudo: true
with_items:
- python-pip
- python-httplib2
- rsync
- subversion
- mercurial
- git
- rubygems
- unzip
- openssl
- make
- gcc
- python-devel
- libselinux-python
when: ansible_os_family == 'RedHat'
- apt: update_cache=yes
when: ansible_os_family == 'Debian'
- name: Install Debian ansible dependencies
apt: name="{{ item }}" state=installed update_cache=yes
sudo: true
with_items:
- python-pip
- python-httplib2
- rsync
- subversion
- mercurial
- git
- unzip
- python-dev
when: ansible_os_family == 'Debian'
- name: Install ubuntu 12.04 ansible dependencies
apt: name="{{ item }}" state=installed update_cache=yes
sudo: true
with_items:
- rubygems
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == "12.04"
- name: Install ubuntu 14.04 ansible dependencies
apt: name="{{ item }}" state=installed update_cache=yes
sudo: true
with_items:
- rubygems-integration
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == "14.04"
- name: Install ansible pip deps
sudo: true
pip: name="{{ item }}"
with_items:
- PyYAML
- Jinja2
- paramiko
- name: Remove tty sudo requirement
sudo: true
lineinfile: "dest=/etc/sudoers regexp='^Defaults[ , ]*requiretty' line='#Defaults requiretty'"
when: ansible_os_family == 'RedHat'

@ -0,0 +1,29 @@
---
- name: Bring up docker containers
hosts: localhost
gather_facts: false
vars:
inventory:
- name: ansible_test_deps_host_1
image: "chrismeyers/centos6"
- name: ansible_test_deps_host_2
image: "chrismeyers/ubuntu12.04"
- name: ansible_test_deps_host_3
image: "ubuntu-upstart:14.04"
roles:
- { role: provision_docker, provision_docker_company: 'ansible', provision_docker_inventory: "{{ inventory }}" }
- name: Run ansible_test_deps Tests
hosts: docker_containers
vars:
git_dir: "/tmp/ansible"
roles:
- { role: ansible_test_deps }
tasks:
- name: Clone ansible
git:
repo: "https://github.com/ansible/ansible.git"
dest: "{{ git_dir }}"
- name: Invoke ansible in hacking mode
shell: "cd {{ git_dir }} && . hacking/env-setup && ansible --version && ansible-playbook --version"

@ -0,0 +1,2 @@
- src: chrismeyersfsu.provision_docker
name: provision_docker

@ -0,0 +1,20 @@
---
- name: Sync ansible repo to ec2 instance
synchronize:
src: "{{ sync_dir }}/"
dest: "~/ansible"
- name: Get ansible source dir
sudo: false
shell: "cd ~ && pwd"
register: results
- shell: ". hacking/env-setup && cd test/integration && make {{ run_integration_make_target }}"
sudo: true
environment:
TEST_FLAGS: "{{ run_integration_test_flags|default(lookup('env', 'TEST_FLAGS')) }}"
CREDENTIALS_FILE: "{{ run_integration_credentials_file|default(lookup('env', 'CREDENTIALS_FILE')) }}"
args:
chdir: "{{ results.stdout }}/ansible"
register: test_results
ignore_errors: true
Loading…
Cancel
Save