Skip to content

Commit

Permalink
Add additional roles (#4)
Browse files Browse the repository at this point in the history
* add ant role

* add molecule test

* update travis

* update readme

* fix lint isues

* add tests folder

* add ant scenario

* try this

* fix role name

* add more tests

* update role readme

* add jfrog,nodejs and openjdk roles and tests

* update readme

* add tag and publish script

* try to run deploy script

* remove dist beta

* move to scripts folder and make executable

* test gh release creation

* rever to main branch

* update EL versios in meta

Co-authored-by: SIANOBRI <[email protected]>
  • Loading branch information
salob and salob authored Oct 7, 2021
1 parent 8ca45ef commit ae5f6c9
Show file tree
Hide file tree
Showing 22 changed files with 472 additions and 6 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ services:
- docker

dist: bionic
group: beta

language: python

Expand Down Expand Up @@ -33,7 +32,8 @@ env:
# ANSIBLE_GALAXY_SERVER_IBM_TOKEN is set using secure environment variables
matrix:
- SCENARIO=apache-ant
- SCENARIO=apache-ant
- SCENARIO=nodejs
- SCENARIO=jfrog

stage: Molecule Tests

Expand All @@ -50,6 +50,7 @@ before_script:
# Fake install cloned collection (required for molecule)
- mkdir -p $HOME/.ansible/collections/$COLLECTION_NAMESPACE
- ln -s ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME $HOME/.ansible/collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
- chmod +x ./scripts/*

script:
# Ansible Molecule tests
Expand All @@ -67,7 +68,7 @@ jobs:

deploy:
- provider: script
script: ./tagAndPublish.sh
script: ./scripts/tagAndPublish.sh
skip_cleanup: true
on:
branch: main
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Description

This collection includes helpful Ansible roles for installing prereq and helper tools for building and testing Cúram Social Program Management.
This collection includes helpful Ansible roles for installing prerequisite software and helper tools for building and testing Cúram Social Program Management.

### Installation

Expand Down
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace: ibm
name: spm_toolbox

# The version of the collection. Must be compatible with semantic versioning
version: 1.0.0
version: 1.0.1

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand Down
12 changes: 12 additions & 0 deletions molecule/jfrog/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: Converge
hosts: all

collections:
- ibm.spm_toolbox

roles:
- jfrog

vars:
jfrog_version: '1.9.0'
31 changes: 31 additions & 0 deletions molecule/jfrog/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
driver:
name: docker
provider:
name: docker

lint: |
set -e
yamllint .
platforms:
- name: centos-8
image: centos:8
dockerfile: ../_resources/Dockerfile.j2
pre_build_image: False
privileged: True
volume_mounts:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
environment:
container: docker

provisioner:
name: ansible
log: true
config_options:
defaults:
stderr_callback: debug
stdout_callback: debug
env:
ANSIBLE_FORCE_COLOR: 'true'
26 changes: 26 additions & 0 deletions molecule/jfrog/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
# This is an example playbook to execute Ansible tests.

- name: Verify
hosts: all
vars:
jfrog_version: '1.9.0'

pre_tasks:
- name: Check if JFrog downloaded
stat:
path: "/usr/local/bin/jfrog"
register: jfrog_check

- name: Check if Jfrog executes
shell: "/usr/local/bin/jfrog -v | grep {{ jfrog_version }}"
register: jfrog_installed

tasks:
- name: Check that jfrog folder exists
assert:
that: jfrog_check.stat.exists

- name: Check jfrog installed and version is correct
assert:
that: jfrog_installed.rc == 0
9 changes: 9 additions & 0 deletions molecule/nodejs/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Converge
hosts: all

collections:
- ibm.spm_toolbox

roles:
- nodejs
31 changes: 31 additions & 0 deletions molecule/nodejs/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
driver:
name: docker
provider:
name: docker

lint: |
set -e
yamllint .
platforms:
- name: centos-8
image: centos:8
dockerfile: ../_resources/Dockerfile.j2
pre_build_image: False
privileged: True
volume_mounts:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
environment:
container: docker

provisioner:
name: ansible
log: true
config_options:
defaults:
stderr_callback: debug
stdout_callback: debug
env:
ANSIBLE_FORCE_COLOR: 'true'
22 changes: 22 additions & 0 deletions molecule/nodejs/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
- name: Verify
hosts: all

pre_tasks:
- stat: "path=/usr/local/bin/node"
register: node_bin
- stat: "path=/usr/local/bin/npm"
register: npm_bin
- stat: "path=/usr/local/bin/npx"
register: npx_bin

tasks:
- name: Check that node exists
assert:
that: node_bin.stat.exists
- name: Check that npm exists
assert:
that: npm_bin.stat.exists
- name: Check that npx exists
assert:
that: npx_bin.stat.exists
2 changes: 1 addition & 1 deletion roles/ant/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
galaxy_info:
author: SPM Development
author: SPM DevOps Team
description: Installs Apache Ant
company: Watson Health SPM

Expand Down
42 changes: 42 additions & 0 deletions roles/jfrog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# jfrog

The `jfrog` role downloads JFrog CLI appropriate for the OS.

## Requirements

None

## Role Variables

| Property Name | Default value |
| ----------------- | ------------- |
| `jfrog_version` | `1.39.5` |
| `jfrog_owner` | `root` |
| `jfrog_group` | `root` |

The `jfrog_version` variable may be set to `$latest` for Linux platforms to download the latest available binary.

## Dependencies

None

## Example Playbook

```
---
- name: Install JFrog CLI
hosts: all
collections:
- ibm.spm_toolbox
roles:
- jfrog
vars:
jfrog_version: "$latest"
```

## License

MIT
4 changes: 4 additions & 0 deletions roles/jfrog/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
jfrog_version: '1.9.0'
jfrog_owner: 'root'
jfrog_group: 'root'
39 changes: 39 additions & 0 deletions roles/jfrog/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
galaxy_info:
author: SPM DevOps Team
description: Download JFrog CLI appropriate for the OS.
company: Watson Health SPM

# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker

license: MIT

min_ansible_version: 2.9

#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: EL
versions:
- '7'
- '8'

galaxy_tags:
[]
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.

dependencies:
[]
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
16 changes: 16 additions & 0 deletions roles/jfrog/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- name: Download Linux jfrog-cli
get_url:
url: "https://releases.jfrog.io/artifactory/jfrog-cli/v1/{{ jfrog_version }}/jfrog-cli-linux-amd64/jfrog"
dest: '/usr/local/bin/jfrog'
owner: "{{ jfrog_owner }}"
group: "{{ jfrog_group }}"
mode: '0755'
when: ansible_os_family != "Windows"

- name: Download Windows jfrog-cli
win_chocolatey:
name: jfrog-cli
version: "{{ jfrog_version }}"
state: present
when: ansible_os_family == "Windows"
36 changes: 36 additions & 0 deletions roles/nodejs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# nodejs

The `nodejs` role downloads NodeJS.

## Requirements

None

## Role Variables

| Property Name | Default value |
| ----------------- | ------------- |
| `nodejs_version` | `v12.21.0` |
| `profiled_path` | `/opt/profile.d` |

## Dependencies

None

## Example Playbook

```
---
- name: Install NodeJS
hosts: all
collections:
- ibm.spm_toolbox
roles:
- nodejs
```

## License

MIT
5 changes: 5 additions & 0 deletions roles/nodejs/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
nodejs_version: v12.21.0

# Common
profiled_path: /opt/profile.d
39 changes: 39 additions & 0 deletions roles/nodejs/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
galaxy_info:
author: SPM DevOps Team
description: Download NodeJS.
company: Watson Health SPM

# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker

license: MIT

min_ansible_version: 2.9

#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: EL
versions:
- '7'
- '8'

galaxy_tags:
[]
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.

dependencies:
[]
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
Loading

0 comments on commit ae5f6c9

Please sign in to comment.