Created
July 3, 2015 05:39
-
-
Save ownport/2aa6773852c9b5ef54bb to your computer and use it in GitHub Desktop.
ansible: maven
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
We will put maven under /opt so we first need to create that directory. | |
- name: Create /opt directory | |
file: path=/opt state=directory | |
We then download the maven3 archive, this time it is more simple, we can directly use the get_url module. | |
- name: Download Maven3 | |
get_url: dest=/opt/maven3.tar.gz url=http://apache.proserve.nl/maven/maven-3/3.0.4/binaries/apache-maven-3.0.4-bin.tar.gz | |
We can then unpack the archive and create a symbolic link to the maven location. | |
- name: Unpack Maven3 | |
action: command creates=/opt/maven chdir=/opt tar zxvf /opt/maven3.tar.gz | |
- name: Create Maven3 directory link | |
file: path=/opt/maven src=/opt/apache-maven-3.0.4 state=link | |
We use again update-alternatives to make mvn accessible platform wide. | |
- name: Set mvn link | |
action: command update-alternatives --install /usr/bin/mvn mvn /opt/maven/bin/mvn 1 | |
We put in place out settings.xml by creating the .m2 directory on the remote computer and copying a settings.xml (we backup any already existing settings.xml). | |
- name: Create .m2 folder | |
file: path=${jenkins_home}/.m2 state=directory owner=jenkins | |
- name: Copy maven configuration | |
copy: src=files/settings.xml dest=${jenkins_home}/.m2/ backup=yes | |
Clean things up. | |
- name: Remove Maven3 archive | |
file: path=/opt/maven3.tar.gz state=absent | |
http://blog.trifork.com/2013/04/02/ansible-example-playbook-to-setup-jenkins-slave/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment