Skip to content

Commit

Permalink
Initial working role
Browse files Browse the repository at this point in the history
  • Loading branch information
kfieldho committed Dec 23, 2015
1 parent c1c8188 commit a678182
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 11 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
Role Name
=========

A brief description of the role goes here.
An Ansible role to fetch and install the latest CMake tarball from the [www.cmake.org](http:https://www.cmake.org) website.

Requirements
------------

Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
None

Role Variables
--------------

A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
* `cmake_version` *3.4.1* The version of CMake to fetch from [cmake.org](http:https://www.cmake.org)
* `cmake_dest_dir` */opt/kitware* Where to install the CMake tarball
* `cmake_modify_path` *True* Add CMake's PATH to .bashrc?

Dependencies
------------

A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
None

Example Playbook
----------------
Expand All @@ -25,7 +27,7 @@ Including an example of how to use your role (for instance, with variables passe

- hosts: servers
roles:
- { role: username.rolename, x: 42 }
- { role: kfieldho.cmake, cmake_version: 3.4.1 }

License
-------
Expand All @@ -35,4 +37,5 @@ BSD
Author Information
------------------

An optional section for the role authors to include contact information, or a website (HTML is not allowed).
Keith Fieldhouse
[email protected]
9 changes: 9 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
---
# defaults file for kfieldho.cmake
cmake_pkg_state: false
cmake_pkg_type: Linux-x86_64
cmake_version: 3.4.1
cmake_temp: /tmp/cmake-{{ cmake_version }}-{{ cmake_pkg_type }}.tar.gz
cmake_dest_dir: /opt/kitware
cmake_install_dir: "{{ cmake_dest_dir }}/cmake-{{cmake_version}}-{{cmake_pkg_type}}/"
cmake_modify_path: True
cmake_rcfile: ~/.bashrc

8 changes: 4 additions & 4 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
galaxy_info:
author: your name
description:
company: your company (optional)
author: Keith R. Fieldhouse
description: Install the latest CMake binary tarball in /opt/kitware
company: Kitware, Inc.
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http:https://example.com/issue/tracker
Expand All @@ -13,7 +13,7 @@ galaxy_info:
# - GPLv3
# - Apache
# - CC-BY
license: license (GPLv2, CC-BY, etc)
license: BSD
min_ansible_version: 1.2
#
# Below are all platforms currently available. Just uncomment
Expand Down
34 changes: 33 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
---
# tasks file for kfieldho.cmake
#4 tasks fil:se for kfieldho.cmake

- name: Check to See if CMake root exists
stat: path={{cmake_dest_dir}}
register: opt_kitware

- name: Ensure installation directory
sudo: True
file: state=directory mode=0755 dest={{cmake_dest_dir}}
when: opt_kitware.stat.exists == False

- name: Check to See if CMake is already installed
stat: path={{ cmake_install_dir }}/bin/cmake
register: bin_cmake
changed_when: bin_cmake.stat.exists == False

- name: Download CMake
get_url: url={{cmake_url}} dest={{cmake_temp}} validate_certs=False
register: cmake_downloaded
when: bin_cmake.stat.exists == False

- name: Install CMake
unarchive: copy=no src={{cmake_temp}} dest={{cmake_dest_dir}}
sudo: True
when: cmake_downloaded | success

- name: Add CMake to the PATH
sudo: no
lineinfile:
dest: "{{ cmake_rcfile }}"
line: export PATH={{ cmake_install_dir }}/bin:$PATH
state: present
when: cmake_modify_path
1 change: 1 addition & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
# vars file for kfieldho.cmake
cmake_url: "https://cmake.org/files/v3.4/cmake-{{ cmake_version }}-{{ cmake_pkg_type }}.tar.gz"

0 comments on commit a678182

Please sign in to comment.