Skip to content

Commit

Permalink
New code
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew B White <[email protected]>
  • Loading branch information
mbwhite committed Feb 3, 2023
1 parent e903601 commit 501d173
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/playbooks/000-hello.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- hosts: localhost
tasks:
- ansible.builtin.debug:
msg: "Hello"


31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Tests

on:
push:
branches:
- main
pull_request:

defaults:
run:
shell: bash

jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Run Playbook
uses: ./
with:
playbook: .github/playbooks/000-hello.yaml




7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM ghcr.io/ibm-blockchain/fabric-ansible:2.0.0-beta
USER root
RUN curl -sSL https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -o /usr/local/bin/jq \
&& chmod +x /usr/local/bin/jq

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
# fabric-ansible-action
GitHub Action to run Ansible Playbooks for Hyperledger Fabric
# :gear: `fabric-ansible-action`
> Action to setup Hyperledger Fabric CLIs
## About

This action will run an Ansible Playbook using the ["Ansible Collection For Fabric"](https://github.com/IBM-Blockchain/ansible-collection)
It is based off the [v2.0.0-beta docker image](https://github.com/IBM-Blockchain/ansible-collection/pkgs/container/fabric-ansible).
## Usage

To run a playbook

```yaml
- name: Create the Fabric Operations Console
uses: hyperledgendary/fabric-ansible-action
with:
playbook: playbooks/operator_console_playbooks/02-console-install.yml
```
To run a playbook with an additional Ansible Arugments file
```yaml
- name: Create the Fabric Operations Console
uses: hyperledgendary/fabric-ansible-action
with:
playbook: playbooks/operator_console_playbooks/02-console-install.yml
argsfile: _cfg/domain.yml
```
## Inputs
The actions supports the following inputs:
- `playbook`: Path to the playbook to run
- `argsfile`: path to an additional args file to supply to Ansible (standard Ansible yaml format)


## License
[APACAHE-2.0](LICENSE).
20 changes: 20 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# action.yml
name: 'Fabric Ansible Action'
description: 'Fabric Ansible Action'
inputs:
playbook: # id of input
description: 'playbook to run'
required: true
default: 'playbook.yaml'
argsfile: # id of input
description: 'additional args file'
required: false
# outputs:
# time: # id of output
# description: 'The time we greeted you'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.playbook }}
- ${{ inputs.argsfile }}
28 changes: 28 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
#
# SPDX-License-Identifier: Apache-2.0
#
set -xeuo pipefail
export INPUT_PLAYBOOK=$1
export ARGSFILE=${2:-none}

echo $INPUT_PLAYBOOK
echo $ARGSFILE

echo $GITHUB_WORKSPACE
whoami
pwd

export PYTHONPATH=/home/ibp-user/.local/lib/python3.9/site-packages
export HOME=/home/ibp-user
# cd ${HOME}

export KUBECONFIG="${GITHUB_WORKSPACE}/_cfg/k8s_context.yaml"

export IBP_ANSIBLE_LOG_FILENAME=${GITHUB_WORKSPACE}/_cfg/__ansible.log

if [[ $ARGSFILE == "none" ]]; then
ansible-playbook -e ROOT=${GITHUB_WORKSPACE} ${GITHUB_WORKSPACE}/${INPUT_PLAYBOOK}
else
ansible-playbook -e ROOT=${GITHUB_WORKSPACE} --extra-vars "@${GITHUB_WORKSPACE}/${ARGSFILE}" ${GITHUB_WORKSPACE}/${INPUT_PLAYBOOK}
fi

0 comments on commit 501d173

Please sign in to comment.