Skip to content

Commit

Permalink
fix: Check if tar is GNU type (#8)
Browse files Browse the repository at this point in the history
* Add gnu-tar check

* F

* F

* Fix

* No fucking linter

* F

* F

* F?

* F

* F

* F

* Upload coll

* F

* Fix ansible version
  • Loading branch information
nahsi authored Feb 9, 2024
1 parent 171526c commit 780b466
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 10 deletions.
50 changes: 41 additions & 9 deletions .github/workflows/ansible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,50 @@ env:
FORCE_COLOR: 1

jobs:
lint:
# lint:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4

# - name: Run ansible-later
# uses: patrickjahns/[email protected]
# with:
# config: .later.yml

# - name: Run ansible-lint
# uses: reviewdog/action-ansiblelint@v1
# with:
# reporter: github-pr-check
# fail_on_error: true

collection:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Run ansible-later
uses: patrickjahns/[email protected]
- name: Setup python
uses: actions/setup-python@v5
with:
config: .later.yml
python-version: "3.x"
cache: pip

- name: Run ansible-lint
uses: reviewdog/action-ansiblelint@v1
- name: Install python dependencies
run: python -m pip install -r requirements.txt

- name: Build collection
run: ansible-galaxy collection build .

- name: Upload collection
uses: actions/upload-artifact@v4
with:
reporter: github-pr-check
fail_on_error: true
path: fluencelabs-provider-*.tar.gz
name: collection
if-no-files-found: error

molecule:
runs-on: ubuntu-latest

needs: lint
needs: collection

strategy:
fail-fast: false
Expand Down Expand Up @@ -65,6 +89,14 @@ jobs:
- name: Install python dependencies
run: python -m pip install -r requirements.txt

- name: Download collection
uses: actions/download-artifact@v4
with:
name: collection

- name: Install collection
run: ansible-galaxy collection install fluencelabs-provider-*.tar.gz

- name: Run ${{ matrix.scenario }} scenario
working-directory: extensions
run: molecule test --scenario-name "${{ matrix.scenario }}"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Fluence provider toolkit.
## Requirements

- Ansible >= 2.12 (might work on older versions)
- gnu-tar on MacOS control host (`brew install gnu-tar`)

## Roles

Expand Down
4 changes: 4 additions & 0 deletions extensions/molecule/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
nox_version: "0.16.13"
nox_project_dir: "molecule"
ipfs_cli_version: "0.25.0"

collections:
- fluencelabs.provider

tasks:
- name: Run nox role
include_role:
Expand Down
4 changes: 4 additions & 0 deletions extensions/molecule/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
nox_project_dir: "molecule"
nox_instances: [0]
ipfs_cli_version: "0.25.0"

collections:
- fluencelabs.provider

tasks:
- name: Run nox role
include_role:
Expand Down
2 changes: 1 addition & 1 deletion meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
requires_ansible: ">=2.16.0"
requires_ansible: ">=2.12.0"
39 changes: 39 additions & 0 deletions plugins/modules/check_tar_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/python

from ansible.module_utils.basic import AnsibleModule
import platform


def check_tar_type(module):
cmd = ['tar', '--version']
rc, out, err = module.run_command(cmd, check_rc=False)

if rc != 0 or ('GNU tar' not in out and 'bsdtar' not in out):
return None, out
if 'GNU tar' in out:
return 'gnu', out
else:
return 'bsd', out


def main():
module = AnsibleModule(
argument_spec={}
)

tar_type, tar_output = check_tar_type(module)

if tar_type == 'gnu':
module.exit_json(
changed=False,
msg="GNU tar is installed.",
tar_type=tar_type)
else:
fail_msg = "Non GNU tar is installed."
if platform.system() == 'Darwin':
fail_msg += " You can install GNU tar with 'brew install gnu-tar'."
module.fail_json(msg=fail_msg, tar_output=tar_output)


if __name__ == '__main__':
main()
4 changes: 4 additions & 0 deletions roles/ipfs_cli/tasks/00-preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@
- nox_dir is string
- nox_dir | length
quiet: true

- name: check that tar is GNU type # noqa
tags: always
fluencelabs.provider.check_tar_type:
4 changes: 4 additions & 0 deletions roles/nox/tasks/00-preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
quiet: true
when: nox_run_id | string | length

- name: check that tar is GNU type # noqa
tags: always
fluencelabs.provider.check_tar_type:

- name: check "nox_instances" variable
tags: always
ansible.builtin.assert:
Expand Down

0 comments on commit 780b466

Please sign in to comment.