diff --git a/.travis.yml b/.travis.yml index a4138d1..f5e3c33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ services: - docker dist: bionic -group: beta language: python @@ -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 @@ -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 @@ -67,7 +68,7 @@ jobs: deploy: - provider: script - script: ./tagAndPublish.sh + script: ./scripts/tagAndPublish.sh skip_cleanup: true on: branch: main diff --git a/README.md b/README.md index efac80d..d598478 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/galaxy.yml b/galaxy.yml index 32b8db2..0622272 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -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 diff --git a/molecule/jfrog/converge.yml b/molecule/jfrog/converge.yml new file mode 100644 index 0000000..2203412 --- /dev/null +++ b/molecule/jfrog/converge.yml @@ -0,0 +1,12 @@ +--- +- name: Converge + hosts: all + + collections: + - ibm.spm_toolbox + + roles: + - jfrog + + vars: + jfrog_version: '1.9.0' diff --git a/molecule/jfrog/molecule.yml b/molecule/jfrog/molecule.yml new file mode 100644 index 0000000..41fbb8f --- /dev/null +++ b/molecule/jfrog/molecule.yml @@ -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' diff --git a/molecule/jfrog/verify.yml b/molecule/jfrog/verify.yml new file mode 100644 index 0000000..5682439 --- /dev/null +++ b/molecule/jfrog/verify.yml @@ -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 diff --git a/molecule/nodejs/converge.yml b/molecule/nodejs/converge.yml new file mode 100644 index 0000000..8a84eec --- /dev/null +++ b/molecule/nodejs/converge.yml @@ -0,0 +1,9 @@ +--- +- name: Converge + hosts: all + + collections: + - ibm.spm_toolbox + + roles: + - nodejs diff --git a/molecule/nodejs/molecule.yml b/molecule/nodejs/molecule.yml new file mode 100644 index 0000000..41fbb8f --- /dev/null +++ b/molecule/nodejs/molecule.yml @@ -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' diff --git a/molecule/nodejs/verify.yml b/molecule/nodejs/verify.yml new file mode 100644 index 0000000..c04515e --- /dev/null +++ b/molecule/nodejs/verify.yml @@ -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 diff --git a/roles/ant/meta/main.yml b/roles/ant/meta/main.yml index 8e5f938..4fcaf44 100644 --- a/roles/ant/meta/main.yml +++ b/roles/ant/meta/main.yml @@ -1,6 +1,6 @@ --- galaxy_info: - author: SPM Development + author: SPM DevOps Team description: Installs Apache Ant company: Watson Health SPM diff --git a/roles/jfrog/README.md b/roles/jfrog/README.md new file mode 100644 index 0000000..b516cac --- /dev/null +++ b/roles/jfrog/README.md @@ -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 diff --git a/roles/jfrog/defaults/main.yml b/roles/jfrog/defaults/main.yml new file mode 100644 index 0000000..6635489 --- /dev/null +++ b/roles/jfrog/defaults/main.yml @@ -0,0 +1,4 @@ +--- +jfrog_version: '1.9.0' +jfrog_owner: 'root' +jfrog_group: 'root' diff --git a/roles/jfrog/meta/main.yml b/roles/jfrog/meta/main.yml new file mode 100644 index 0000000..f6d9bbb --- /dev/null +++ b/roles/jfrog/meta/main.yml @@ -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. diff --git a/roles/jfrog/tasks/main.yml b/roles/jfrog/tasks/main.yml new file mode 100644 index 0000000..52e2cca --- /dev/null +++ b/roles/jfrog/tasks/main.yml @@ -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" diff --git a/roles/nodejs/README.md b/roles/nodejs/README.md new file mode 100644 index 0000000..78ce9c9 --- /dev/null +++ b/roles/nodejs/README.md @@ -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 diff --git a/roles/nodejs/defaults/main.yml b/roles/nodejs/defaults/main.yml new file mode 100644 index 0000000..b11b5fc --- /dev/null +++ b/roles/nodejs/defaults/main.yml @@ -0,0 +1,5 @@ +--- +nodejs_version: v12.21.0 + +# Common +profiled_path: /opt/profile.d diff --git a/roles/nodejs/meta/main.yml b/roles/nodejs/meta/main.yml new file mode 100644 index 0000000..f21343a --- /dev/null +++ b/roles/nodejs/meta/main.yml @@ -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. diff --git a/roles/nodejs/tasks/main.yml b/roles/nodejs/tasks/main.yml new file mode 100644 index 0000000..c856dd2 --- /dev/null +++ b/roles/nodejs/tasks/main.yml @@ -0,0 +1,71 @@ +--- +- name: Check if NodeJS binaries exist + stat: + path: /usr/local/bin/node + register: node_check + +- name: Check Node version + command: /usr/local/bin/node --version + ignore_errors: yes + changed_when: false + register: node_version_check + +- name: Install + when: not node_check.stat.exists or nodejs_version not in node_version_check.stdout + block: + - name: Cleanup previous install + file: + path: /usr/local/bin/node + state: absent + + - name: Download and unarchive NodeJS + unarchive: + src: https://nodejs.org/dist/{{ nodejs_version }}/node-{{ nodejs_version }}-linux-x64.tar.xz + dest: /usr/local/ + remote_src: true + mode: 0755 + + - name: Create NodeJS symlinks + file: + src: /usr/local/node-{{ nodejs_version }}-linux-x64/bin/{{ item }} + dest: /usr/local/bin/{{ item }} + state: link + loop: + - npm + - npx + - node + +- name: "Create {{ profiled_path }}" + file: + path: "{{ profiled_path }}" + mode: 0755 + state: directory + +- name: "Create {{ profiled_path }}/node.sh" + copy: + dest: "{{ profiled_path }}/node.sh" + content: | + #!/bin/bash + export NODEJS_HOME=/usr/local/node-{{ nodejs_version }}-linux-x64 + export PATH=$NODEJS_HOME/bin:$PATH + mode: 0755 + +- name: Create /opt/.profile + copy: + dest: /opt/.profile + content: | + #!/bin/bash + PATH=.:$PATH + + if [ -e {{ profiled_path }} ]; then + if [ "$PS1" ]; then + ls -l {{ profiled_path }}/*.sh + fi + for lizard in {{ profiled_path }}/*.sh ; do + . $lizard + done + fi + + LANG=en_US.ISO-8859-1 + umask 002 + mode: 0755 diff --git a/roles/openjdk/README.md b/roles/openjdk/README.md new file mode 100644 index 0000000..f0c383a --- /dev/null +++ b/roles/openjdk/README.md @@ -0,0 +1,33 @@ +# openjdk + +The `openjdk` role downloads OpenJDK 8. + +## Requirements + +None + +## Role Variables + +None + +## Dependencies + +None + +## Example Playbook + +``` +--- +- name: Install OS openjdk-devel package + hosts: all + + collections: + - ibm.spm_toolbox + + roles: + - openjdk +``` + +## License + +MIT diff --git a/roles/openjdk/meta/main.yml b/roles/openjdk/meta/main.yml new file mode 100644 index 0000000..68522f0 --- /dev/null +++ b/roles/openjdk/meta/main.yml @@ -0,0 +1,39 @@ +--- +galaxy_info: + author: SPM DevOps Team + description: Download OpenJDK8. + 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. diff --git a/roles/openjdk/tasks/main.yml b/roles/openjdk/tasks/main.yml new file mode 100644 index 0000000..388225b --- /dev/null +++ b/roles/openjdk/tasks/main.yml @@ -0,0 +1,10 @@ +--- +- name: Install yum + yum: + name: which + state: present + +- name: Download OpenJDK8 + yum: + name: java-1.8.0-openjdk-devel + state: present diff --git a/tagAndPublish.sh b/scripts/tagAndPublish.sh similarity index 100% rename from tagAndPublish.sh rename to scripts/tagAndPublish.sh