Skip to content

Commit

Permalink
Merge pull request #2 from maaaikoool/master
Browse files Browse the repository at this point in the history
Idempotence fix and travis test support
  • Loading branch information
maaaikoool committed Jan 13, 2015
2 parents fabcec5 + ae30395 commit 1bc845d
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 6 deletions.
30 changes: 30 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
language: python
python: "2.7"

before_install:
- sudo apt-get update -qq
- sudo apt-get install -y curl

install:
# Install Ansible.
- pip install ansible

# Add ansible.cfg to pick up roles path.
- "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg"

script:
# Check the role/playbook's syntax.
- "ansible-playbook -i tests/hosts tests/test.yml --syntax-check"

# Run the role/playbook with ansible-playbook.
- "ansible-playbook -i tests/hosts tests/test.yml --connection=local --sudo"

# Run the role/playbook again, checking to make sure it's idempotent.
- >
ansible-playbook -i tests/hosts tests/test.yml --connection=local --sudo
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Make sure nexus is running
- curl http://localhost:8081/nexus
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Ansible Nexus OSS Role

[![Build Status](https://travis-ci.org/maaaikoool/ansible-nexus-oss.svg?branch=master)](https://travis-ci.org/maaaikoool/ansible-nexus-oss)

## Description

*ansible-nexus-oss* is an [Ansible](http://ansible.com) role.
Expand Down
14 changes: 13 additions & 1 deletion tasks/base.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
---
# tasks file for base

- name: check current timezone
shell: cat /etc/timezone
register: current_zone
changed_when: False

- name: check current localtime
shell: cat /etc/localtime
register: current_time
changed_when: False

- name: Change timezone
copy: "content='{{ timezone }}' dest=/etc/timezone owner=root group=root mode=0644 backup=yes"
when: current_zone.stdout != timezone
notify: update timezone
tags: base

- name: Change localtime
copy: "src=/usr/share/zoneinfo/{{ timezone }} dest=/etc/localtime"
when: current_time.stdout != timezone
tags: base

- name: Install packages
apt: pkg={{ item }} state=latest
with_items:
Expand Down
7 changes: 2 additions & 5 deletions tasks/nexus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
tags: nexus

- name: Download Nexus
command: >
wget http://download.sonatype.com/nexus/oss/nexus-{{ nexus.version }}-bundle.tar.gz
chdir=/tmp
creates=/tmp/nexus-{{ nexus.version }}-bundle.tar.gz
get_url: url=http://download.sonatype.com/nexus/oss/nexus-{{ nexus.version }}-bundle.tar.gz dest=/tmp
tags: nexus

- name: Create Nexus directory
Expand Down Expand Up @@ -73,7 +70,7 @@
tags: nexus

- name: Enable Nexus service
service: name=nexus enabled=yes
service: name=nexus enabled=yes state=started
notify: restart nexus
tags: nexus

Expand Down
2 changes: 2 additions & 0 deletions tests/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[nexus]
localhost
7 changes: 7 additions & 0 deletions tests/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- hosts: nexus
gather_facts: yes
roles:
- ansible-nexus-oss
tasks:
- wait_for: port=8081 delay=10

0 comments on commit 1bc845d

Please # to comment.