Skip to content

Commit

Permalink
Red wash (#6)
Browse files Browse the repository at this point in the history
* test publish, quick redwash

* trigger on actions on test branch

* api key name

* try to use personal user
some problem

* .github/main

* do not need artifactory

* ci requirements looks too old

* update readme

* update format and version

---------

Co-authored-by: Roman Muntean <[email protected]>
  • Loading branch information
huangjien and romakarol authored Nov 9, 2023
1 parent e3b1a55 commit 28f0453
Show file tree
Hide file tree
Showing 24 changed files with 233 additions and 25 deletions.
8 changes: 8 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# [Choice] Debian OS version (use bullseye on local arm64/Apple Silicon): bookworm, buster, bullseye
ARG VARIANT="bullseye"
# FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/base:${VARIANT}
FROM mcr.microsoft.com/devcontainers/base:${VARIANT}

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
30 changes: 30 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
{
"name": "molecule",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
//"image": "mcr.microsoft.com/devcontainers/java:8",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers-contrib/features/curl-apt-get:1": {},
"ghcr.io/devcontainers-contrib/features/jfrog-cli-npm:1": {},
//"ghcr.io/devcontainers-contrib/features/jmeter-sdkman:2": {},
"ghcr.io/devcontainers/features/python:1": {}
},

"overrideFeatureInstallOrder": [
"ghcr.io/devcontainers/features/common-utils",
"ghcr.io/devcontainers/features/git",
"ghcr.io/devcontainers/features/github-cli:1",
"ghcr.io/devcontainers-contrib/features/curl-apt-get:1",
"ghcr.io/devcontainers-contrib/features/zsh-plugins",
"ghcr.io/devcontainers/features/docker-in-docker"
//"ghcr.io/jungaretti/features/make:1"
]
}

83 changes: 83 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
# This is a basic workflow to help you get started with Actions

name: ci

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events
# but only for the main branch
push:
branches: [main]
pull_request:
branches: ['*']

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs
# that can run sequentially or in parallel
jobs:
ci:
env:
CUSTOM_CHECKOUT_LOC: "repo"
python_ver: "3.10"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
scenario:
- apache-ant
- jfrog
- nodejs
steps:
- name: Checkout
uses: actions/checkout@v2
with:
path: ${{ env.CUSTOM_CHECKOUT_LOC }}
- name: Setup Python v${{ env.python_ver }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.python_ver }}
cache: 'pip'
# remove android and dotnet to gain more spaces for oracle installation
- name: Maximize build space
run: |
ls
ls -la "${{ env.CUSTOM_CHECKOUT_LOC }}"
df -h
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
df -h
- name: Install dependencies
run: |
cd ${{ env.CUSTOM_CHECKOUT_LOC }}
python -m pip install -U pip
python -m pip install -r requirements.txt
- name: Prepare environment
run: |
cd ${{ env.CUSTOM_CHECKOUT_LOC }}
export COLLECTION_NAMESPACE=$(yq e '.namespace' galaxy.yml)
export COLLECTION_NAME=$(yq e '.name' galaxy.yml)
export COLLECTION_VERSION=$(yq e '.version' galaxy.yml)
export NEW_REPO_LOC=ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
echo "NEW_REPO_LOC=$NEW_REPO_LOC" >> $GITHUB_ENV
# export REPO_CLONE_FOLDERNAME=${PWD##*/}
# Create folder structure required by ansible-test and other tooling
cd ..
mkdir -p ansible_collections/$COLLECTION_NAMESPACE
mv ${{ env.CUSTOM_CHECKOUT_LOC }} ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
cd ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
ls -la
# 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
# - name: Sanity checks
# run: |
# ansible-test sanity --docker -v --color --python ${{ env.python_ver }}
- name: Molecule
run: |
cd ${{ env.NEW_REPO_LOC }}
ls -la
molecule test -s ${{ matrix.scenario }}
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: release

# Controls when the workflow will run
on:
# Triggers the workflow on push
push:
# branches: [main]
branches: releaseActions

# A workflow run is made up of one or more jobs
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Deploy the collection
uses: artis3n/ansible_galaxy_collection@v2
with:
api_key: ${{ secrets.GALAXY_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.gitconfig
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
# GH actions used now instead of Travis. Kept for reference

sudo: required

services:
Expand Down
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,34 @@ This collection includes helpful Ansible roles for installing prerequisite softw

Install via Ansible Galaxy:

`ansible-galaxy collection install ibm.spm_toolbox`
`ansible-galaxy collection install merative.spm_toolbox`

Or include this collection in your playbook's requirements.yml file:

```
---
collections:
- name: ibm.spm_toolbox
- name: merative.spm_toolbox
```

### Develop in VS Code dev container

You can use VS Code dev container in the project.

After container started, just run:

```
pip install -r requirements.txt
```

Then you can do molecule testing:

```
export ARTIFACTORY_URL=https://[your company or personal artifactory url]/artifactory
export ARTIFACTORY_REPO=software-installer-repo
export ARTIFACTORY_TOKEN=[token to your artifactory]
export LOCAL_PATH=/opt/spm-middleware
molecule test -s jfrog --destroy never
```

Happy Coding!
8 changes: 4 additions & 4 deletions galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
# The namespace of the collection. This can be a company/brand/organization or product namespace under which all
# content lives. May only contain alphanumeric characters and underscores. Additionally namespaces cannot start with
# underscores or numbers and cannot contain consecutive underscores
namespace: ibm
namespace: merative

# The name of the collection. Has the same character restrictions as 'namespace'
name: spm_toolbox

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

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand All @@ -28,8 +28,8 @@ description: A suite for installing tools required for SPM build and test.
# accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file'
license_file: LICENSE

repository: https://github.com/IBM/spm-toolbox
issues: https://github.com/IBM/spm-toolbox/issues
repository: https://github.com/Merative/spm-toolbox
issues: https://github.com/Merative/spm-toolbox/issues

tags:
- spm
Expand Down
2 changes: 1 addition & 1 deletion molecule/__apache-ant/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
hosts: all

collections:
- ibm.spm_toolbox
- merative.spm_toolbox

pre_tasks:
- name: Install JDK
Expand Down
26 changes: 26 additions & 0 deletions molecule/_resources/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Molecule managed

{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM --platform=linux/amd64 {{ item.image }}
{% endif %}

RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python3 python3-pip sudo python3-devel python3-dnf bash findutils which unzip zip procps python3-libselinux && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash findutils which unzip zip procps && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi

# Create `ansible` user with sudo permissions and membership in `DEPLOY_GROUP`
ENV ANSIBLE_USER=ansible DEPLOY_GROUP=deployer
RUN set -xe \
&& if [ $(getent group wheel) ]; then export SUDO_GROUP=wheel; fi \
&& if [ $(getent group sudo) ]; then export SUDO_GROUP=sudo; fi \
&& groupadd -r ${ANSIBLE_USER} \
&& groupadd -r ${DEPLOY_GROUP} \
&& useradd -m -g ${ANSIBLE_USER} ${ANSIBLE_USER} \
&& usermod -aG ${SUDO_GROUP} ${ANSIBLE_USER} \
&& usermod -aG ${DEPLOY_GROUP} ${ANSIBLE_USER} \
&& sed -i "/^%${SUDO_GROUP}/s/ALL\$/NOPASSWD:ALL/g" /etc/sudoers
4 changes: 2 additions & 2 deletions molecule/apache-ant/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ lint: |
yamllint .
platforms:
- name: centos-8
image: centos:8
- name: rockylinux8
image: rockylinux:8
dockerfile: ../_resources/Dockerfile.j2
pre_build_image: False
privileged: True
Expand Down
4 changes: 2 additions & 2 deletions molecule/jfrog/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
hosts: all

collections:
- ibm.spm_toolbox
- merative.spm_toolbox

roles:
- jfrog

vars:
jfrog_version: '1.9.0'
jfrog_version: '1.54.1'
4 changes: 2 additions & 2 deletions molecule/jfrog/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ lint: |
yamllint .
platforms:
- name: centos-8
image: centos:8
- name: rockylinux8
image: rockylinux:8
dockerfile: ../_resources/Dockerfile.j2
pre_build_image: False
privileged: True
Expand Down
2 changes: 1 addition & 1 deletion molecule/jfrog/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- name: Verify
hosts: all
vars:
jfrog_version: '1.9.0'
jfrog_version: '1.54.1'

pre_tasks:
- name: Check if JFrog downloaded
Expand Down
2 changes: 1 addition & 1 deletion molecule/nodejs/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
hosts: all

collections:
- ibm.spm_toolbox
- merative.spm_toolbox

roles:
- nodejs
4 changes: 2 additions & 2 deletions molecule/nodejs/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ lint: |
yamllint .
platforms:
- name: centos-8
image: centos:8
- name: rockylinux8
image: rockylinux:8
dockerfile: ../_resources/Dockerfile.j2
pre_build_image: False
privileged: True
Expand Down
9 changes: 9 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ansible
pywinrm
molecule
molecule-docker
docker
ansible-lint
yamllint
passlib
jmespath
2 changes: 1 addition & 1 deletion roles/ant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ A compatible JDK installed
hosts: all
collections:
- ibm.spm_toolbox
- merative.spm_toolbox
pre_tasks:
- name: Install JDK
Expand Down
2 changes: 1 addition & 1 deletion roles/jfrog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ None
hosts: all
collections:
- ibm.spm_toolbox
- merative.spm_toolbox
roles:
- jfrog
Expand Down
2 changes: 1 addition & 1 deletion roles/jfrog/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
jfrog_version: '1.9.0'
jfrog_version: '1.54.1'
jfrog_owner: 'root'
jfrog_group: 'root'
4 changes: 2 additions & 2 deletions roles/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ None

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

## Dependencies
Expand All @@ -25,7 +25,7 @@ None
hosts: all
collections:
- ibm.spm_toolbox
- merative.spm_toolbox
roles:
- nodejs
Expand Down
2 changes: 1 addition & 1 deletion roles/nodejs/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
nodejs_version: v12.21.0
nodejs_version: v18.12.0

# Common
profiled_path: /opt/profile.d
8 changes: 7 additions & 1 deletion roles/nodejs/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@
path: /usr/local/bin/node
state: absent

- name: Print download url
ansible.builtin.debug:
msg: https://nodejs.org/dist/{{ nodejs_version }}/node-{{ nodejs_version }}-linux-x64.tar.gz

- name: Download and unarchive NodeJS
unarchive:
src: https://nodejs.org/dist/{{ nodejs_version }}/node-{{ nodejs_version }}-linux-x64.tar.xz
src: https://nodejs.org/dist/{{ nodejs_version }}/node-{{ nodejs_version }}-linux-x64.tar.gz
dest: /usr/local/
remote_src: true
mode: 0755
# extra_opts:
# - '-xf'

- name: Create NodeJS symlinks
file:
Expand Down
Loading

0 comments on commit 28f0453

Please sign in to comment.