Created
January 8, 2015 07:46
-
-
Save kafecho/ae9f6cf1540647dd5cc5 to your computer and use it in GitHub Desktop.
Prototype Ansible playbook to install CouchDB and Silverlight on Windows nodes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$p = Start-Process -FilePath "C:\Users\Guillaume\couchdb.exe" -ArgumentList "/VerySilent /CLOSEAPPLICATIONS /Log=C:\couchdb.txt" -Wait -PassThru | |
$p.WaitForExit() | |
if ($p.ExitCode -ne 0) { | |
throw "failed" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ansible playbook to install and configure CouchDB from scratch. | |
--- | |
# The steps below run on the Ansible 'master' node. | |
- hosts: 127.0.0.1 | |
sudo: True | |
connection: local | |
vars: | |
# Some customisations to the CouchDB configuration. | |
couchdb_port: 5983 | |
couchdb_bind_address: 0.0.0.0 | |
tasks: | |
# I use a web server to serve content from the master node to the windows machine. | |
# This approach also enables offline mode, where the Windows node don't have access to the internet | |
- name: install Apache2 on the Ansible master node | |
yum: name=httpd | |
- name: create the ansible folder that will be served by Apache2 | |
file: path=/var/www/html/ansible state=directory | |
- name: retrieve the Windows installer for CouchDB | |
get_url: url=http://apache.is.co.za/couchdb/binary/win/1.6.1/setup-couchdb-1.6.1_R16B02.exe dest=/var/www/html/ansible/couchdb.exe force=no | |
- name: add a copy of the Silverlight windows installer to the web server folder | |
copy: src=Silverlight_x64.exe dest=/var/www/html/ansible/Silverlight_x64.exe | |
# Templating is not yet supported in Windows, so we template the file on the master node and serve the output via http | |
- name: create a CouchDB local.ini file from a template and save it to the local webserver. | |
template: src=local.ini.j2 dest=/var/www/html/ansible/local.ini | |
- name: ensure that Apache2 is running | |
service: name=httpd state=started | |
# The steps below run on any Windows node in the inventory | |
- hosts: windows | |
gather_facts: no | |
tasks: | |
# We discover the ip address of the master node, so that windows nodes can fetch content over Http from the right place | |
- name: fetch the ip address of the master node | |
local_action: "shell ifconfig eth1 | grep 'inet addr' | awk -F: '{print $2}' | awk '{print $1}'" | |
register: ansible_master_ip | |
- name: download the Silverlight installer from the Ansible master node | |
win_get_url: url=http://{{ ansible_master_ip.stdout }}/ansible/Silverlight_x64.exe dest=C:\Users\Guillaume\silverlight.exe | |
- name: proceed to a silent install of silverlight | |
script: installsilverlight.ps1 | |
- name: download the couchdb.exe InnoSetup installer from the Ansible master node | |
win_get_url: url=http://{{ ansible_master_ip.stdout }}/ansible/couchdb.exe dest=C:\Users\Guillaume\couchdb.exe | |
- name: ensure that CouchDB is stopped | |
win_service: name="Apache CouchDB" state=stopped | |
ignore_errors: true | |
- name: stop left-over Erlang processes (otherwise, the installation via PowerShell will fail) | |
script: stoperlang.ps1 | |
- name: proceed to a silent install of couchdb | |
script: installcouchdb.ps1 | |
- name: customize the CouchDB configuration | |
win_get_url: url=http://{{ ansible_master_ip.stdout }}/ansible/local.ini dest='C:\Program Files (x86)\Apache Software Foundation\CouchDB\etc\couchdb\local.ini' | |
- name: restart couchdb | |
win_service: name="Apache CouchDB" state=restarted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment