diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..0e5316a --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,42 @@ +--- +name: Test deployment +'on': + pull_request: + push: + schedule: + # Run every Wednesday at 01:42 + - cron: "42 1 * * 3" + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Check out codebase + uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: pip3 install yamllint + - name: Lint repository + run: yamllint . + + molecule: + name: Molecule + runs-on: ubuntu-latest + steps: + - name: Check out the codebase + uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: pip3 install ansible molecule[docker] docker pytest testinfra + - name: Run Molecule + run: molecule test + env: + PY_COLORS: '1' + ANSIBLE_FORCE_COLOR: '1' diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..2102f83 --- /dev/null +++ b/.yamllint @@ -0,0 +1,34 @@ +--- + +yaml-files: + - '*.yaml' + - '*.yml' + - '.yamllint' + +rules: + braces: enable + brackets: enable + colons: enable + commas: enable + comments: + level: warning + comments-indentation: + level: warning + document-end: disable + document-start: + level: warning + empty-lines: enable + empty-values: disable + hyphens: enable + indentation: enable + key-duplicates: enable + key-ordering: disable + line-length: + level: warning + new-line-at-end-of-file: enable + new-lines: enable + octal-values: disable + quoted-strings: disable + trailing-spaces: enable + truthy: + level: warning diff --git a/README.md b/README.md index f8d20db..007e920 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Test deployment](https://github.com/GeekOops/geekoops-next/actions/workflows/CI.yml/badge.svg)](https://github.com/GeekOops/geekoops-next/actions/workflows/CI.yml) + # geekoops-next Install and configure a NEXT (Network Boot) server using `dnsmasq`. diff --git a/files/next.tar.bz2 b/files/next.tar.bz2 deleted file mode 100644 index f71401b..0000000 Binary files a/files/next.tar.bz2 and /dev/null differ diff --git a/files/next.zip b/files/next.zip new file mode 100644 index 0000000..814db29 Binary files /dev/null and b/files/next.zip differ diff --git a/meta/main.yml b/meta/main.yml index 227ad9c..b8606d7 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,53 +1,23 @@ +--- galaxy_info: - author: your name - description: your role description - company: your company (optional) - - # If the issue tracker for your role is not on github, uncomment the - # next line and provide a value + author: Felix Niederwanger + description: Configurable nginx setup role + company: SUSE # issue_tracker_url: http://example.com/issue/tracker - - # Choose a valid license ID from https://spdx.org - some suggested licenses: - # - BSD-3-Clause (default) - # - MIT - # - GPL-2.0-or-later - # - GPL-3.0-only - # - Apache-2.0 - # - CC-BY-4.0 - license: license (GPL-2.0-or-later, MIT, etc) + license: MIT min_ansible_version: 2.9 # If this a Container Enabled role, provide the minimum Ansible Container version. # min_ansible_container_version: - # - # 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: Fedora - # versions: - # - all - # - 25 - # - name: SomePlatform - # versions: - # - all - # - 1.0 - # - 7 - # - 99.99 + platforms: + - name: opensuse + versions: + - 15.2 - 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. + galaxy_tags: ['pxe', 'next', 'netboot'] dependencies: [] - # List your role dependencies here, one per line. Be sure to remove the '[]' above, - # if you add dependencies to this list. - \ No newline at end of file diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml new file mode 100644 index 0000000..4b52780 --- /dev/null +++ b/molecule/default/converge.yml @@ -0,0 +1,7 @@ +--- +- name: Converge + hosts: all + tasks: + - name: "Include geekoops-next" + include_role: + name: "geekoops-next" diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 0000000..10b7c55 --- /dev/null +++ b/molecule/default/molecule.yml @@ -0,0 +1,29 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: leap15_2 + image: grisu48/leap-ansible + pre_build_image: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + capabilities: + - SYS_ADMIN + privileged: true + tmpfs: + - /run + - /tmp +provisioner: + name: ansible + inventory: + host_vars: + leap15_2: +verifier: + name: testinfra + lint: + name: flake8 +lint: | + set -e + yamllint . diff --git a/molecule/default/tests/test_default.py b/molecule/default/tests/test_default.py new file mode 100755 index 0000000..8167fdf --- /dev/null +++ b/molecule/default/tests/test_default.py @@ -0,0 +1,17 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + + +import testinfra.utils.ansible_runner +import os + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + +def test_pxe(host): + # TODO: Extend the test coverage. + tftpboot = "/srv/tftpboot" + cmd = host.run("curl -v tftp://127.0.0.1/pxelinux.0 -o /tmp/pxelinux.0") + print(cmd.stdout) + assert cmd.succeeded + cmd = host.run(f'diff {tftpboot}/pxelinux.0 /tmp/pxelinux.0') + assert cmd.succeeded diff --git a/tasks/main.yml b/tasks/main.yml index 2b7d256..98fd373 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -10,7 +10,7 @@ package: name: "{{ packages }}" state: present - tags: ['dnsmasq','tftp'] + tags: ['dnsmasq', 'tftp'] - name: Configure dnsmasq template: src: dnsmasq.j2 @@ -19,7 +19,7 @@ group: root mode: 0755 notify: restart dnsmasq - tags: ['dnsmasq','tftp'] + tags: ['dnsmasq', 'tftp'] - name: Ensure pxelinux.cfg is present file: path: "{{tftp_root}}/pxelinux.cfg" @@ -27,16 +27,16 @@ owner: root group: root mode: 0755 - tags: ['dnsmasq','tftp'] + tags: ['dnsmasq', 'tftp'] - name: Extract NEXT template unarchive: - src: next.tar.bz2 + src: next.zip dest: "{{tftp_root}}/" owner: root group: root mode: 0755 keep_newer: yes - tags: ['dnsmasq','tftp'] + tags: ['dnsmasq', 'tftp'] - name: Configure pxelinux.cfg default template: src: pxelinux_default.j2 @@ -44,14 +44,15 @@ owner: root group: root mode: 0755 - tags: ['dnsmasq','tftp'] + force: no + tags: ['dnsmasq', 'tftp'] - name: Ensure dnsmasq is started and enabled systemd: name: "{{ dnsmasq_service }}" state: started enabled: true - tags: ['dnsmasq','tftp'] + tags: ['dnsmasq', 'tftp'] - include: firewall.yml when: config_firewall == true diff --git a/vars/main.yml b/vars/main.yml index b501bcb..92aa308 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,2 +1,2 @@ --- -# vars file for geekoops-next \ No newline at end of file +# vars file for geekoops-next diff --git a/vars/openSUSE Leap_15.2.yml b/vars/openSUSE Leap_15.2.yml index cfe6e17..1b5a79f 100644 --- a/vars/openSUSE Leap_15.2.yml +++ b/vars/openSUSE Leap_15.2.yml @@ -3,9 +3,8 @@ ## Software packages -packages: ['dnsmasq'] +packages: ['dnsmasq', 'unzip'] dnsmasq_service: "dnsmasq" tftp_root: "/srv/tftpboot" -