From e9bd497eaf98396d6d6aefc64cd10ee75634bc8a Mon Sep 17 00:00:00 2001 From: N Date: Sat, 21 Sep 2019 18:50:47 +0100 Subject: [PATCH 01/10] refactor(statenames): renamed remove to clean --- README.rst | 16 ++++++++-------- lvm/clean.sls | 11 +++++++++++ lvm/files/clean.sls | 30 ++++++++++++++++++++++++++++++ lvm/files/remove.sls | 31 ++----------------------------- lvm/lv/clean.sls | 22 ++++++++++++++++++++++ lvm/lv/remove.sls | 23 ++--------------------- lvm/osfamilymap.yaml | 37 +++++++++++++++++++++++++++++++------ lvm/profiles/clean.sls | 23 +++++++++++++++++++++++ lvm/profiles/remove.sls | 24 ++---------------------- lvm/pv/clean.sls | 22 ++++++++++++++++++++++ lvm/pv/remove.sls | 23 ++--------------------- lvm/remove.sls | 8 +------- lvm/vg/clean.sls | 22 ++++++++++++++++++++++ lvm/vg/remove.sls | 23 ++--------------------- 14 files changed, 180 insertions(+), 135 deletions(-) create mode 100644 lvm/clean.sls create mode 100644 lvm/files/clean.sls create mode 100644 lvm/lv/clean.sls create mode 100644 lvm/profiles/clean.sls create mode 100644 lvm/pv/clean.sls create mode 100644 lvm/vg/clean.sls diff --git a/README.rst b/README.rst index 44e0b1d..e920a5e 100644 --- a/README.rst +++ b/README.rst @@ -46,11 +46,11 @@ Available substates .. contents:: :local: -``lvm.remove`` +``lvm.clean`` ------------ Remove lvm2 software. -``lvm.profiles.remove`` +``lvm.profiles.clean`` ---------------------- Remove custom lvm profile(s):: @@ -66,11 +66,11 @@ Install lvm2 package. ---------- Configure PVs, VGs and LVs using legacy pillar data (backwards compatibility only). -``lvm.remove`` +``lvm.clean`` ------------ Remove lvm2 software. -``lvm.profiles.remove`` +``lvm.profiles.clean`` ---------------------- Remove custom lvm profile(s):: @@ -91,7 +91,7 @@ Create custom lvm profile(s):: thin_pool_autoextend_percent: 20 -``lvm.files.remove`` +``lvm.files.clean`` ------------------ Remove LVM backing files from the file system. @@ -125,7 +125,7 @@ LVM Loopback HOW-TO support. Creates backing files (in /tmp by defaults) and loo /dev/loop1: #hopefully /tmp/testfile2.img (run 'sudo losetup -D' first for certainty) -``lvm.pv.remove`` +``lvm.pv.clean`` -------------- Remove physical volumes (PVs):: @@ -220,7 +220,7 @@ Make volume groups known to the system:: options: verbose: True -``lvm.vg.remove`` +``lvm.vg.clean`` -------------- Remove volume group(s):: @@ -348,7 +348,7 @@ Restore the metadata of VG(s) from text backup files produced by ``lvm.vg.cfgbac -``lvm.lv.remove`` +``lvm.lv.clean`` --------------- Remove LV(s):: diff --git a/lvm/clean.sls b/lvm/clean.sls new file mode 100644 index 0000000..169e594 --- /dev/null +++ b/lvm/clean.sls @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls + +## Automate tasks in logical sequence ... + +include: + - lvm.lv.clean + - lvm.vg.clean + - lvm.pv.clean + - lvm.profiles.clean + - lvm.files.clean diff --git a/lvm/files/clean.sls b/lvm/files/clean.sls new file mode 100644 index 0000000..d4d3172 --- /dev/null +++ b/lvm/files/clean.sls @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls +{% from "lvm/map.jinja" import lvm with context %} + + {%- if "remove" in lvm.files and lvm.files.remove is iterable and lvm.files.remove is not string %} + {% set loopdevs = salt['cmd.shell']('losetup -a | cut -d: -f1').split('\n') or [] %} + {%- for file in lvm.files.remove %} + + {%- for loopdev in loopdevs %} + {%- if loopdev %} +lvm file losetup delete {{ loopdev|lower }} if attached to {{ file }}: + cmd.run: + - name: losetup --detach {{ loopdev }} + - onlyif: losetup -a | grep {{ loopdev }} | grep {{ file }} + {%- endif %} + {% endfor %} + +lvm file remove {{ file }}: + file.absent: + - name: {{ file }} + + {% endfor %} + {%- else %} + +lvm_files_remove_nothing_to_do: + test.show_notification: + - text: | + No "files.remove" pillar data supplied - nothing to do! + + {%- endif %} diff --git a/lvm/files/remove.sls b/lvm/files/remove.sls index d4d3172..b79f926 100644 --- a/lvm/files/remove.sls +++ b/lvm/files/remove.sls @@ -1,30 +1,3 @@ -# -*- coding: utf-8 -*- -# vim: ft=sls -{% from "lvm/map.jinja" import lvm with context %} - {%- if "remove" in lvm.files and lvm.files.remove is iterable and lvm.files.remove is not string %} - {% set loopdevs = salt['cmd.shell']('losetup -a | cut -d: -f1').split('\n') or [] %} - {%- for file in lvm.files.remove %} - - {%- for loopdev in loopdevs %} - {%- if loopdev %} -lvm file losetup delete {{ loopdev|lower }} if attached to {{ file }}: - cmd.run: - - name: losetup --detach {{ loopdev }} - - onlyif: losetup -a | grep {{ loopdev }} | grep {{ file }} - {%- endif %} - {% endfor %} - -lvm file remove {{ file }}: - file.absent: - - name: {{ file }} - - {% endfor %} - {%- else %} - -lvm_files_remove_nothing_to_do: - test.show_notification: - - text: | - No "files.remove" pillar data supplied - nothing to do! - - {%- endif %} +include: + - .clean diff --git a/lvm/lv/clean.sls b/lvm/lv/clean.sls new file mode 100644 index 0000000..b73de45 --- /dev/null +++ b/lvm/lv/clean.sls @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls +{% from "lvm/map.jinja" import lvm with context %} +{% from "lvm/templates/macros.jinja" import getopts with context %} + +{%- if lvm.lv and "remove" in lvm.lv and lvm.lv.remove is mapping %} + {%- for lv, lvdata in lvm.lv.remove.items() %} + +lvm_lv_clean_{{ lv }}: + cmd.run: + - name: lvremove --yes {{ getopts(lvdata) }} {{ lv }} + - onlyif: lvdisplay {{ lv }} 2>/dev/null + + {%- endfor %} +{%- else %} + +lvm_lv_clean_nothing_to_do: + test.show_notification: + - text: | + No "lv.remove" pillar data supplied - nothing to do! + +{%- endif %} diff --git a/lvm/lv/remove.sls b/lvm/lv/remove.sls index d036d4c..b79f926 100644 --- a/lvm/lv/remove.sls +++ b/lvm/lv/remove.sls @@ -1,22 +1,3 @@ -# -*- coding: utf-8 -*- -# vim: ft=sls -{% from "lvm/map.jinja" import lvm with context %} -{% from "lvm/templates/macros.jinja" import getopts with context %} -{%- if lvm.lv and "remove" in lvm.lv and lvm.lv.remove is mapping %} - {%- for lv, lvdata in lvm.lv.remove.items() %} - -lvm_lv_remove_{{ lv }}: - cmd.run: - - name: lvremove --yes {{ getopts(lvdata) }} {{ lv }} - - onlyif: lvdisplay {{ lv }} 2>/dev/null - - {%- endfor %} -{%- else %} - -lvm_lv_remove_nothing_to_do: - test.show_notification: - - text: | - No "lv.remove" pillar data supplied - nothing to do! - -{%- endif %} +include: + - .clean diff --git a/lvm/osfamilymap.yaml b/lvm/osfamilymap.yaml index 29cbde8..8335600 100644 --- a/lvm/osfamilymap.yaml +++ b/lvm/osfamilymap.yaml @@ -1,13 +1,20 @@ # -*- coding: utf-8 -*- -# vim: ft=jinja - -Default: - pkgs: - - thin-provisioning-tools - +# vim: ft=yaml +# +# Setup variables using grains['os_family'] based logic. +# You just need to add the key:values for an `os_family` that differ +# from `defaults.yaml` + `osarch.yaml`. +# Only add an `os_family` which is/will be supported by the formula. +# +# If you do not need to provide defaults via the `os_family` grain, +# you will need to provide at least an empty dict in this file, e.g. +# osfamilymap: {} +--- Debian: kmodules: - dm_thin_pool + pkgs: + - thin-provisioning-tools RedHat: pkgs: @@ -22,3 +29,21 @@ RedHat: command_profile_templater: {} cache-smq: {} lvmdbusd: {} + +Arch: + pkgs: + - thin-provisioning-tools + +OpenBSD: + rootgroup: wheel + +Suse: + pkgs: + - thin-provisioning-tools + +Gentoo: {} +Alpine: {} +FreeBSD: {} +Solaris: {} +Windows: {} +MacOS: {} diff --git a/lvm/profiles/clean.sls b/lvm/profiles/clean.sls new file mode 100644 index 0000000..865e9bc --- /dev/null +++ b/lvm/profiles/clean.sls @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls +{% from "lvm/map.jinja" import lvm with context %} + +{%- if "remove" in lvm.profiles and lvm.profiles.remove is mapping %} + {% for profile in lvm.profiles.remove %} + {% if profile and "profile" not in lvm.profiles.default %} + +lvm_profiles_clean_{{ profile }}: + file.absent: + - name: {{ lvm.config.dir.profiles }}/{{ profile }} + - onlyif: test -f {{ lvm.config.dir.profiles }}/{{ profile }} + + {% endif %} + {% endfor %} +{%- else %} + +lvm_profiles_clean_nothing_to_do: + test.show_notification: + - text: | + No "profiles.remove" pillar data supplied - nothing to do! + +{%- endif %} diff --git a/lvm/profiles/remove.sls b/lvm/profiles/remove.sls index 0dca02d..b79f926 100644 --- a/lvm/profiles/remove.sls +++ b/lvm/profiles/remove.sls @@ -1,23 +1,3 @@ -# -*- coding: utf-8 -*- -# vim: ft=sls -{% from "lvm/map.jinja" import lvm with context %} -{%- if "remove" in lvm.profiles and lvm.profiles.remove is mapping %} - {% for profile in lvm.profiles.remove %} - {% if profile and "profile" not in lvm.profiles.default %} - -lvm_profiles_remove_{{ profile }}: - file.absent: - - name: {{ lvm.config.dir.profiles }}/{{ profile }} - - onlyif: test -f {{ lvm.config.dir.profiles }}/{{ profile }} - - {% endif %} - {% endfor %} -{%- else %} - -lvm_profiles_remove_nothing_to_do: - test.show_notification: - - text: | - No "profiles.remove" pillar data supplied - nothing to do! - -{%- endif %} +include: + - .clean diff --git a/lvm/pv/clean.sls b/lvm/pv/clean.sls new file mode 100644 index 0000000..fbbab03 --- /dev/null +++ b/lvm/pv/clean.sls @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls +{% from "lvm/map.jinja" import lvm with context %} +{% from "lvm/templates/macros.jinja" import getopts with context %} + +{%- if lvm.pv and "remove" in lvm.pv and lvm.pv.remove is mapping %} + {%- for pv, pvdata in lvm.pv.remove.items() %} + +lvm_pv_clean_{{ pv }}: + cmd.run: + - name: pvremove --yes {{ getopts(pvdata) }} {{ pv }} + - onlyif: pvdisplay {{ pv }} 2>/dev/null + + {%- endfor %} +{%- else %} + +lvm_pv_clean_nothing_to_do: + test.show_notification: + - text: | + No "pv.remove" pillar data supplied - nothing to do! + +{%- endif %} diff --git a/lvm/pv/remove.sls b/lvm/pv/remove.sls index 4065427..b79f926 100644 --- a/lvm/pv/remove.sls +++ b/lvm/pv/remove.sls @@ -1,22 +1,3 @@ -# -*- coding: utf-8 -*- -# vim: ft=sls -{% from "lvm/map.jinja" import lvm with context %} -{% from "lvm/templates/macros.jinja" import getopts with context %} -{%- if lvm.pv and "remove" in lvm.pv and lvm.pv.remove is mapping %} - {%- for pv, pvdata in lvm.pv.remove.items() %} - -lvm_pv_remove_{{ pv }}: - cmd.run: - - name: pvremove --yes {{ getopts(pvdata) }} {{ pv }} - - onlyif: pvdisplay {{ pv }} 2>/dev/null - - {%- endfor %} -{%- else %} - -lvm_pv_remove_nothing_to_do: - test.show_notification: - - text: | - No "pv.remove" pillar data supplied - nothing to do! - -{%- endif %} +include: + - .clean diff --git a/lvm/remove.sls b/lvm/remove.sls index 1dfb69c..43f3b24 100644 --- a/lvm/remove.sls +++ b/lvm/remove.sls @@ -1,11 +1,5 @@ # -*- coding: utf-8 -*- # vim: ft=sls -## Automate tasks in logical sequence ... - include: - - lvm.lv.remove - - lvm.vg.remove - - lvm.pv.remove - - lvm.profiles.remove - - lvm.files.remove + - .clean diff --git a/lvm/vg/clean.sls b/lvm/vg/clean.sls new file mode 100644 index 0000000..cf6e59a --- /dev/null +++ b/lvm/vg/clean.sls @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls +{% from "lvm/map.jinja" import lvm with context %} +{% from "lvm/templates/macros.jinja" import getopts with context %} + +{%- if lvm.vg and "remove" in lvm.vg and lvm.vg.remove is mapping %} + {%- for vg, vgdata in lvm.vg.remove.items() %} + +lvm_vg_clean_{{ vg }}: + cmd.run: + - name: vgremove --yes {{ getopts(vgdata) }} {{ vg }} + - onlyif: vgdisplay {{ vg }} 2>/dev/null + + {%- endfor %} +{%- else %} + +lvm_vg_clean_nothing_to_do: + test.show_notification: + - text: | + No "vg.remove" pillar data supplied - nothing to do! + +{%- endif %} diff --git a/lvm/vg/remove.sls b/lvm/vg/remove.sls index 2173e54..b79f926 100644 --- a/lvm/vg/remove.sls +++ b/lvm/vg/remove.sls @@ -1,22 +1,3 @@ -# -*- coding: utf-8 -*- -# vim: ft=sls -{% from "lvm/map.jinja" import lvm with context %} -{% from "lvm/templates/macros.jinja" import getopts with context %} -{%- if lvm.vg and "remove" in lvm.vg and lvm.vg.remove is mapping %} - {%- for vg, vgdata in lvm.vg.remove.items() %} - -lvm_vg_remove_{{ vg }}: - cmd.run: - - name: vgremove --yes {{ getopts(vgdata) }} {{ vg }} - - onlyif: vgdisplay {{ vg }} 2>/dev/null - - {%- endfor %} -{%- else %} - -lvm_vg_remove_nothing_to_do: - test.show_notification: - - text: | - No "vg.remove" pillar data supplied - nothing to do! - -{%- endif %} +include: + - .clean From 1db02375cab8f5715caec427f6b2de1a86ef4826 Mon Sep 17 00:00:00 2001 From: N Date: Sat, 21 Sep 2019 18:52:24 +0100 Subject: [PATCH 02/10] fix(packages): map thin-provisioning-tools package --- lvm/oscodename.yaml | 37 +++++++++++++++++++++++++++++++++++++ lvm/osfingermap.yaml | 24 ++++++++++++++++++++++++ lvm/osmap.yaml | 21 +++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 lvm/oscodename.yaml create mode 100644 lvm/osfingermap.yaml create mode 100644 lvm/osmap.yaml diff --git a/lvm/oscodename.yaml b/lvm/oscodename.yaml new file mode 100644 index 0000000..f920e35 --- /dev/null +++ b/lvm/oscodename.yaml @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +# +{% macro debian_codename(name, codename=none) %} +{{ codename|default(name, true) }}: +{% endmacro %} + +{% macro fedora_codename(name, release, codename) %} +{{ codename|default(name, true) }}: +{% endmacro %} + +## Debian GNU/Linux +{{ debian_codename('wheezy') }} +{{ debian_codename('jessie') }} +{{ debian_codename('stretch') }} +{{ debian_codename('buster') }} +{{ debian_codename('bullseye') }} + + ## `oscodename` is longname if `lsb-release` not installed +{{ debian_codename('wheezy', 'Debian GNU/Linux 7 (wheezy)') }} +{{ debian_codename('jessie', 'Debian GNU/Linux 8 (jessie)') }} +{{ debian_codename('stretch', 'Debian GNU/Linux 9 (stretch)') }} +{{ debian_codename('buster', 'Debian GNU/Linux 10 (buster)') }} +{{ debian_codename('bullseye', 'Debian GNU/Linux 11 (bullseye)') }} + +## Ubuntu +{{ debian_codename('trusty', 'trusty') }} +{{ debian_codename('xenial', 'xenial') }} +{{ debian_codename('artful', 'artful') }} +{{ debian_codename('bionic', 'bionic') }} +{{ debian_codename('cosmic', 'cosmic') }} + +## Fedora +# `oscodename` grain has long distro name +{{ fedora_codename('Fedora-29', 29, 'Fedora 29 (Twenty Nine)') }} + +# vim: ft=sls diff --git a/lvm/osfingermap.yaml b/lvm/osfingermap.yaml new file mode 100644 index 0000000..0d24c45 --- /dev/null +++ b/lvm/osfingermap.yaml @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +# +# Setup variables using grains['osfinger'] based logic. +# You just need to add the key:values for an `osfinger` that differ +# from `defaults.yaml` + `osarch.yaml` + `os_family.yaml` + `osmap.yaml`. +# Only add an `osfinger` which is/will be supported by the formula. +# +# If you do not need to provide defaults via the `os_finger` grain, +# you will need to provide at least an empty dict in this file, e.g. +# osfingermap: {} +--- +# os: CentOS +CentOS-6: + pkgs: + - thin-provisioning-tools + +CentOS-7: + pkgs: + - device-mapper-persistent-data #aka thin-provisioning-tools + +CentOS-8: + pkgs: + - device-mapper-persistent-data #aka thin-provisioning-tools diff --git a/lvm/osmap.yaml b/lvm/osmap.yaml new file mode 100644 index 0000000..0a2664c --- /dev/null +++ b/lvm/osmap.yaml @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +# +# Setup variables using grains['os'] based logic. +# You just need to add the key:values for an `os` that differ +# from `defaults.yaml` + `osarch.yaml` + `os_family.yaml`. +# Only add an `os` which is/will be supported by the formula. +# +# If you do not need to provide defaults via the `os` grain, +# you will need to provide at least an empty dict in this file, e.g. +# osmap: {} +--- +# os_family: RedHat +Fedora: + pkgs: + - device-mapper-persistent-data #aka thin-provisioning-tools + +# os_family: RedHat +Amazon: + pkgs: + - device-mapper-persistent-data #aka thin-provisioning-tools From 0d5e74e8ac8674fbfe14a7c6422b2962105f12be Mon Sep 17 00:00:00 2001 From: N Date: Sat, 21 Sep 2019 18:54:49 +0100 Subject: [PATCH 03/10] test(travis): add basic travis setup --- .travis.yml | 86 ++++ kitchen.yml | 172 ++++++++ lvm/map.jinja | 68 ++- test/integration/default/README.md | 50 +++ .../default/controls/config_spec.rb | 4 + .../default/controls/packages_spec.rb | 4 + .../default/controls/services_spec.rb | 6 + .../controls/subcomponent_config_spec.rb | 4 + test/integration/default/inspec.yml | 17 + test/salt/pillar/define_roles.sls | 7 + test/salt/pillar/pillar.example | 399 ++++++++++++++++++ 11 files changed, 805 insertions(+), 12 deletions(-) create mode 100644 .travis.yml create mode 100644 kitchen.yml create mode 100644 test/integration/default/README.md create mode 100644 test/integration/default/controls/config_spec.rb create mode 100644 test/integration/default/controls/packages_spec.rb create mode 100644 test/integration/default/controls/services_spec.rb create mode 100644 test/integration/default/controls/subcomponent_config_spec.rb create mode 100644 test/integration/default/inspec.yml create mode 100644 test/salt/pillar/define_roles.sls create mode 100644 test/salt/pillar/pillar.example diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2e1631f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,86 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- +dist: bionic +stages: + - test + - lint + - name: release + if: branch = master AND type != pull_request + +sudo: required +cache: bundler +language: ruby + +services: + - docker + +# Make sure the instances listed below match up with +# the `platforms` defined in `kitchen.yml` +env: + matrix: + - INSTANCE: default-debian-10-develop-py3 + # - INSTANCE: default-ubuntu-1804-develop-py3 + # - INSTANCE: default-centos-7-develop-py3 + - INSTANCE: default-fedora-30-develop-py3 + # - INSTANCE: default-opensuse-leap-15-develop-py3 + # - INSTANCE: default-amazonlinux-2-develop-py2 + # - INSTANCE: default-debian-9-2019-2-py3 + - INSTANCE: default-ubuntu-1804-2019-2-py3 + - INSTANCE: default-centos-7-2019-2-py3 + # - INSTANCE: default-fedora-30-2019-2-py3 + # - INSTANCE: default-opensuse-leap-15-2019-2-py3 + # INSTANCE: default-amazonlinux-2-2019-2-py2 + # - INSTANCE: default-debian-9-2018-3-py2 + # - INSTANCE: default-ubuntu-1604-2018-3-py2 + # INSTANCE: default-centos-7-2018-3-py2 + # INSTANCE: default-fedora-29-2018-3-py2 + - INSTANCE: default-opensuse-leap-15-2018-3-py2 + - INSTANCE: default-amazonlinux-2-2018-3-py2 + # - INSTANCE: default-debian-8-2017-7-py2 + # - INSTANCE: default-ubuntu-1604-2017-7-py2 + # INSTANCE: default-centos-6-2017-7-py2 + # - INSTANCE: default-fedora-29-2017-7-py2 + # - INSTANCE: default-opensuse-leap-15-2017-7-py2 + # - INSTANCE: default-amazonlinux-2-2017-7-py2 + +script: + - bin/kitchen verify ${INSTANCE} + +jobs: + include: + # Define the `lint` stage (runs `yamllint` and `commitlint`) + - stage: lint + language: node_js + node_js: lts/* + before_install: skip + script: + # Install and run `yamllint` + # Need at least `v1.17.0` for the `yaml-files` setting + - pip install --user yamllint>=1.17.0 + - yamllint -s . + # Install and run `commitlint` + - npm install @commitlint/config-conventional -D + - npm install @commitlint/travis-cli -D + - commitlint-travis + # Define the release stage that runs `semantic-release` + - stage: release + language: node_js + node_js: lts/* + before_install: skip + script: + # Update `AUTHORS.md` + - export MAINTAINER_TOKEN=${GH_TOKEN} + - go get github.com/myii/maintainer + - maintainer contributor + + # Install all dependencies required for `semantic-release` + - npm install @semantic-release/changelog@3 -D + - npm install @semantic-release/exec@3 -D + - npm install @semantic-release/git@7 -D + deploy: + provider: script + skip_cleanup: true + script: + # Run `semantic-release` + - npx semantic-release@15 diff --git a/kitchen.yml b/kitchen.yml new file mode 100644 index 0000000..be76fcc --- /dev/null +++ b/kitchen.yml @@ -0,0 +1,172 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- +# For help on this file's format, see https://kitchen.ci/ +driver: + name: docker + use_sudo: false + privileged: true + run_command: /lib/systemd/systemd + +# Make sure the platforms listed below match up with +# the `env.matrix` instances defined in `.travis.yml` +platforms: + ## SALT `develop` + - name: debian-10-develop-py3 + driver: + image: netmanagers/salt-develop-py3:debian-10 + provision_command: + - curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com + - sh bootstrap-salt.sh -XdPbfrq -x python3 git develop + - name: ubuntu-1804-develop-py3 + driver: + image: netmanagers/salt-develop-py3:ubuntu-18.04 + provision_command: + - curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com + - sh bootstrap-salt.sh -XdPbfrq -x python3 git develop + - name: centos-7-develop-py3 + driver: + image: netmanagers/salt-develop-py3:centos-7 + provision_command: + - curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com + - sh bootstrap-salt.sh -XdPbfrq -x python3 git develop + - name: fedora-30-develop-py3 + driver: + image: netmanagers/salt-develop-py3:fedora-30 + provision_command: + - curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com + - sh bootstrap-salt.sh -XdPbfrq -x python3 git develop + - name: opensuse-leap-15-develop-py3 + driver: + image: netmanagers/salt-develop-py3:opensuse-leap-15 + provision_command: + - curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com + - sh bootstrap-salt.sh -XdPbfrq -x python3 git develop + run_command: /usr/lib/systemd/systemd + # Workaround to avoid intermittent failures on `opensuse-leap-15`: + # => SCP did not finish successfully (255): (Net::SCP::Error) + transport: + max_ssh_sessions: 1 + - name: amazonlinux-2-develop-py2 + driver: + image: netmanagers/salt-develop-py2:amazonlinux-2 + provision_command: + - curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com + - sh bootstrap-salt.sh -XdPbfrq -x python2 git develop + + ## SALT `2019.2` + - name: debian-9-2019-2-py3 + driver: + image: netmanagers/salt-2019.2-py3:debian-9 + - name: ubuntu-1804-2019-2-py3 + driver: + image: netmanagers/salt-2019.2-py3:ubuntu-18.04 + - name: centos-7-2019-2-py3 + driver: + image: netmanagers/salt-2019.2-py3:centos-7 + - name: fedora-30-2019-2-py3 + driver: + image: netmanagers/salt-2019.2-py3:fedora-30 + - name: opensuse-leap-15-2019-2-py3 + driver: + image: netmanagers/salt-2019.2-py3:opensuse-leap-15 + run_command: /usr/lib/systemd/systemd + # Workaround to avoid intermittent failures on `opensuse-leap-15`: + # => SCP did not finish successfully (255): (Net::SCP::Error) + transport: + max_ssh_sessions: 1 + - name: amazonlinux-2-2019-2-py2 + driver: + image: netmanagers/salt-2019.2-py2:amazonlinux-2 + + ## SALT `2018.3` + - name: debian-9-2018-3-py2 + driver: + image: netmanagers/salt-2018.3-py2:debian-9 + - name: ubuntu-1604-2018-3-py2 + driver: + image: netmanagers/salt-2018.3-py2:ubuntu-16.04 + - name: centos-7-2018-3-py2 + driver: + image: netmanagers/salt-2018.3-py2:centos-7 + - name: fedora-29-2018-3-py2 + driver: + image: netmanagers/salt-2018.3-py2:fedora-29 + - name: opensuse-leap-15-2018-3-py2 + driver: + image: netmanagers/salt-2018.3-py2:opensuse-leap-15 + run_command: /usr/lib/systemd/systemd + # Workaround to avoid intermittent failures on `opensuse-leap-15`: + # => SCP did not finish successfully (255): (Net::SCP::Error) + transport: + max_ssh_sessions: 1 + - name: amazonlinux-2-2018-3-py2 + driver: + image: netmanagers/salt-2018.3-py2:amazonlinux-2 + + ## SALT `2017.7` + - name: debian-8-2017-7-py2 + driver: + image: netmanagers/salt-2017.7-py2:debian-8 + - name: ubuntu-1604-2017-7-py2 + driver: + image: netmanagers/salt-2017.7-py2:ubuntu-16.04 + - name: centos-6-2017-7-py2 + driver: + image: netmanagers/salt-2017.7-py2:centos-6 + run_command: /sbin/init + - name: fedora-29-2017-7-py2 + driver: + image: netmanagers/salt-2017.7-py2:fedora-29 + - name: opensuse-leap-15-2017-7-py2 + driver: + image: netmanagers/salt-2017.7-py2:opensuse-leap-15 + run_command: /usr/lib/systemd/systemd + # Workaround to avoid intermittent failures on `opensuse-leap-15`: + # => SCP did not finish successfully (255): (Net::SCP::Error) + transport: + max_ssh_sessions: 1 + - name: amazonlinux-2-2017-7-py2 + driver: + image: netmanagers/salt-2017.7-py2:amazonlinux-2 + +provisioner: + name: salt_solo + log_level: info + salt_install: none + require_chef: false + formula: lvm + salt_copy_filter: + - .kitchen + - .git + +verifier: + # https://www.inspec.io/ + name: inspec + sudo: true + # cli, documentation, html, progress, json, json-min, json-rspec, junit + reporter: + - cli + +suites: + - name: default + provisioner: + dependencies: + - name: lvm + repo: git + source: https://github.com/saltstack-formulas/lvm-formula.git + state_top: + base: + '*': + - lvm.clean + - lvm + pillars: + top.sls: + base: + '*': + - lvm + pillars_from_files: + lvm.sls: test/salt/pillar/pillar.example + verifier: + inspec_tests: + - path: test/integration/default diff --git a/lvm/map.jinja b/lvm/map.jinja index 075186d..c02bc51 100644 --- a/lvm/map.jinja +++ b/lvm/map.jinja @@ -1,16 +1,60 @@ -#Defaults -{% import_yaml "lvm/defaults.yaml" as defaults %} -{% import_yaml "lvm/osfamilymap.yaml" as osfamilymap %} - -# Merge site-specific data -{% set lvm = salt['grains.filter_by']( - defaults, - merge=salt['grains.filter_by']( +# -*- coding: utf-8 -*- +# vim: ft=jinja + +{#- Get the `tplroot` from `tpldir` #} +{%- set tplroot = tpldir.split('/')[0] %} +{#- Start imports as #} +{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %} +{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %} +{%- import_yaml tplroot ~ "/osmap.yaml" as osmap %} +{%- import_yaml tplroot ~ "/oscodename.yaml" as oscodename %} +{%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %} + + +{#- Retrieve the config dict only once #} +{%- set _config = salt['config.get'](tplroot, default={}) %} + +{%- set defaults = salt['grains.filter_by']( + default_settings, + default=tplroot, + merge=salt['grains.filter_by']( osfamilymap, - merge=salt['config.get']('lvm', {}), - ), - base='lvm', -) %} + grain='os_family', + merge=salt['grains.filter_by']( + osmap, + grain='os', + merge=salt['grains.filter_by']( + oscodename, + grain='oscodename', + merge=salt['grains.filter_by']( + osfingermap, + grain='osfinger', + merge=salt['grains.filter_by']( + _config, + default='lookup' + ) + ) + ) + ) + ) + ) +%} + +{%- set config = salt['grains.filter_by']( + {'defaults': defaults}, + default='defaults', + merge=_config + ) +%} + +{%- set lvm = config %} + +{#- Post-processing for specific non-YAML customisations #} +{%- if grains.os == 'MacOS' %} +{%- set macos_group = salt['cmd.run']("stat -f '%Sg' /dev/console") %} +{%- do lvm.update({'rootgroup': macos_group}) %} +{%- endif %} + ## legacy remove in future ## {% set os_family_map = salt['grains.filter_by']({ diff --git a/test/integration/default/README.md b/test/integration/default/README.md new file mode 100644 index 0000000..37cf963 --- /dev/null +++ b/test/integration/default/README.md @@ -0,0 +1,50 @@ +# InSpec Profile: `default` + +This shows the implementation of the `default` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md). + +## Verify a profile + +InSpec ships with built-in features to verify a profile structure. + +```bash +$ inspec check default +Summary +------- +Location: default +Profile: profile +Controls: 4 +Timestamp: 2019-06-24T23:09:01+00:00 +Valid: true + +Errors +------ + +Warnings +-------- +``` + +## Execute a profile + +To run all **supported** controls on a local machine use `inspec exec /path/to/profile`. + +```bash +$ inspec exec default +.. + +Finished in 0.0025 seconds (files took 0.12449 seconds to load) +8 examples, 0 failures +``` + +## Execute a specific control from a profile + +To run one control from the profile use `inspec exec /path/to/profile --controls name`. + +```bash +$ inspec exec default --controls package +. + +Finished in 0.0025 seconds (files took 0.12449 seconds to load) +1 examples, 0 failures +``` + +See an [example control here](https://github.com/inspec/inspec/blob/master/examples/profile/controls/example.rb). diff --git a/test/integration/default/controls/config_spec.rb b/test/integration/default/controls/config_spec.rb new file mode 100644 index 0000000..be41d56 --- /dev/null +++ b/test/integration/default/controls/config_spec.rb @@ -0,0 +1,4 @@ +control 'lvm configuration' do + title 'should match desired lines' + +end diff --git a/test/integration/default/controls/packages_spec.rb b/test/integration/default/controls/packages_spec.rb new file mode 100644 index 0000000..4884bbd --- /dev/null +++ b/test/integration/default/controls/packages_spec.rb @@ -0,0 +1,4 @@ +# Overide by OS +control 'template package' do + title 'should be installed' +end diff --git a/test/integration/default/controls/services_spec.rb b/test/integration/default/controls/services_spec.rb new file mode 100644 index 0000000..1f55ee1 --- /dev/null +++ b/test/integration/default/controls/services_spec.rb @@ -0,0 +1,6 @@ +# Overide by OS +control 'lvm service' do + impact 0.5 + title 'should be running and enabled' + +end diff --git a/test/integration/default/controls/subcomponent_config_spec.rb b/test/integration/default/controls/subcomponent_config_spec.rb new file mode 100644 index 0000000..46808c8 --- /dev/null +++ b/test/integration/default/controls/subcomponent_config_spec.rb @@ -0,0 +1,4 @@ +control 'lvm subcomponent configuration' do + title 'should match desired lines' + +end diff --git a/test/integration/default/inspec.yml b/test/integration/default/inspec.yml new file mode 100644 index 0000000..e15862a --- /dev/null +++ b/test/integration/default/inspec.yml @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- +name: default +title: lvm formula +maintainer: SaltStack Formulas +license: Apache-2.0 +summary: Verify that the lvm formula is setup and configured correctly +supports: + - platform-name: debian + - platform-name: ubuntu + - platform-name: centos + - platform-name: fedora + - platform-name: opensuse + - platform-name: suse + - platform-name: freebsd + - platform-name: amazon diff --git a/test/salt/pillar/define_roles.sls b/test/salt/pillar/define_roles.sls new file mode 100644 index 0000000..bfd8b69 --- /dev/null +++ b/test/salt/pillar/define_roles.sls @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- +# libtofs.jinja must work with tofs.files_switch looked up list +roles: + - foo + - bar diff --git a/test/salt/pillar/pillar.example b/test/salt/pillar/pillar.example new file mode 100644 index 0000000..5d4f009 --- /dev/null +++ b/test/salt/pillar/pillar.example @@ -0,0 +1,399 @@ +# vim: sts=2 ts=2 sw= et ai +# +# for legacy pillar support (backward compatibility) see bottom of file + +lvm: + pkg: lvm2 + group: root + + config: + dir: + profiles: /etc/lvm/profile + backups: /etc/lvm/backup + + profiles: + remove: + - sillyprofile + create: + thin-generic-autoextend: + activation: + thin_pool_autoextend_threshold: 70 + thin_pool_autoextend_percent: 20 + + files: + #loopbackdir: /tmp/loopdevs #Where to create backing files? + remove: + - /tmp/loopdevs/testfile1.img + - /tmp/loopdevs/testfile2.img + create: + truncate: #Shrink or extend the size of each FILE to the specified size + testfile1.img: + options: + size: 100M + dd: #copy a file, converting and formatting according to the operands + /tmp/loopdevs/testfile2.img: + options: + if: /dev/urandom + bs: 1024 + count: 204800 + losetup: #setup loop devices. todo: could be 'list' instead. + /tmp/loopdevs/testfile1.img: {} + /tmp/loopdevs/testfile2.img: {} + pv: + create: + /dev/loop0: #hopefully /tmp/loopdevs/testfile1.img + /dev/loop1: #hopefully /tmp/loopdevs/testfile2.img + + pv: + remove: + /tmp/loopdevs/loopback1: + options: + verbose: True + loopback: + size: 10G + encryption: none + /dev/sdb: + options: + verbose: True + /dev/sdc: + options: + debug: True + /dev/sdd: + /dev/sde: + /dev/sdf: + change: + ##Named PV must belong to VG; i.e. PV must be allocatable + /dev/sdd: + options: + addtag: 'goodpvs' + deltag: 'badpvs' + debug: 1 + resize: + /dev/sdd: + options: + setphysicalvolumesize: 1G + move: + ##(Named LV and) old PV must be in same VG; i.e. PVs must be allocatable + /dev/sdd: + dest: /dev/sde + options: + #name: vg00/lv1 + noudevsync: True + create: + /dev/sdb: + /dev/sdc: + options: + verbose: True + /dev/sdd: + /dev/sde: + options: + override: True + dataalignmentoffset: 7s + metadatacopies: 1 + metadatasize: 40MiB + /dev/sdf: + + vg: + cfgbackup: + vg00: + file: vg00_backup_today + options: + quiet: True + + import: + i_do_not_exist: + options: + verbose: True + + remove: + vg00: + options: + noudevsync: True + vg_large: + options: + noudevsync: True + + change: + vg00: + options: + available: True + syncronize: False + addtag: 'goodvgs' + deltag: 'badvgs' + + reduce: + vg00: + devices: + - /dev/sdb + options: + removemissing: True + + extend: + vg00: + devices: + - /dev/sdd + options: + restoremissing: True + + split: + vg00: + newvg: smallvg + devices: + - /dev/sdf + options: + clustered: n + maxphysicalvolumes: 0 + maxlogicalvolumes: 0 + + merge: + vg00: + withvg: vg001 + options: + debug: True + + rename: + vg002: + newname: vg2 + options: + debug: True + + create: + vg00: + devices: + - /dev/sdb + - /dev/sdc + options: + clustered: n + maxlogicalvolumes: 0 + maxphysicalvolumes: 0 + physicalextentsize: 1024 + vg_large: + devices: + - /dev/sdd + - /dev/sde + - /dev/sdf + + export: + vg_tmp: + options: + verbose: True + commandprofile: command_profile_template + + cfgrestore: + vg00: + file: vg00_backup_today + + lv: + remove: + lv_pool1: + vgname: vg_large + lv_pool1_meta: + vgname: vg_large + lvol0: + vgname: vg_large + lvol1: + vgname: vg_large + lvol2: + vgname: vg_large + lvol3: + vgname: vg_large + lvol4: + vgname: vg_large + lvol5: + vgname: vg_large + lvol6: + vgname: vg_large + my_raid1: + vgname: vg_large + options: + force: True + + change: + vg00/lv1: + options: + permission: r + activate: n + addtag: 'goodlvs' + deltag: 'badlvs' + + reduce: + vg00/lv1: + options: + extents: -2 + vg00/lv2: + options: + size: -20MiB + + extend: + vg00/lv1: + options: + #extents: +100%PVS + extents: 2 + devices: + - /dev/sdf + + rename: + vg00/lv11: + vgname: vg00 + newname: lvolvo + + create: + lv1: + vgname: vg00 + size: 200MiB + options: + addtag: 'Coolvolume' + contiguous: y + monitor: y + lv_stripe1: + vgname: vg00 + options: + extents: 1 + stripes: 2 + stripesize: 4096 + #following pillars support snapshots: see https://github.com/saltstack/salt/issues/48808 + sparse: + vgname: vg00 + snapshot: True + sourcelv: lv1 + options: + size: 200MiB + lv2_snap: + vgname: vg00 + snapshot: True + sourcelv: lv2 + options: + size: '+10%ORIGIN' + devices: + - /dev/sdc:0-7 + - /dev/sdd:0-7 + # untested ... + lv_raid5: + vgname: vg00 + size: 5MiB + options: + type: raid5 + stripes: 3 + stripesize: 64 + #lv_raid10_a: + # vgname: vg00 + # options: + # type: raid10 + # size: 5MiB + # stripes: 2 + # mirrors: 1 + + # data logical volume for thinLV + lv_pool1: + vgname: vg_large + size: 1G + devices: + - /dev/sdd:0-7 + # thin metadata logical volume for thinLV + lv_pool1_meta: + vgname: vg_large + size: 50MiB + devices: + - /dev/sdd:0-7 + # thin LV + lv_thin1: + vgname: lv_thinpool1 + thinvolume: True + size: 50M + options: + virtualsize: 1G + lv_raid10_b: + vgname: vg_large + size: 100MiB + options: + stripes: 2 + stripesize: 64 + chunksize: 256 + thin: True #thinlogicalvolume + thinpool: lv_pool1 + virtualsize: 1G + background: True + + convert: + ##thin pool logical volume + vg_large/lv_thinpool1: + options: + type: thin-pool + ##data and metadata LVs in a thin pool are best created on separate physical devices + poolmetadata: + - lv_pool1_meta + - lv_pool1 + vg_large/lv_pool1: + options: + type: thin-pool + vg_large/lv_1: + options: + mirrors: 1 + mirrorlog: core + devices: + - /dev/sdd:0-15 + - /dev/sdd:0-15 + vg_large/lv_mirror1: + options: + splitmirrors: 1 + name: lv_split + regionsize: 512KB + background: False + interval: 10 + noudevsync: False + devices: + - /dev/sde + - /dev/sdf + + filesystems: + create: + /dev/vg00/lv1: + options: + type: gfs + options: '-plock_nolock -j 1' + mount: True + onboot: True + onboot_opts: + +### LEGACY PILLAR SUPPORT ### + +lvm: + lv: + lv1: + name: lv_data1 + vgname: vg_data + options: + size: 1g + stripes: 5 + stripesize: 8K + thinpool: True + thinvolume: True + lv_data2: + enabled: False # this lv will be removed + vgname: vg_data2 + options: + size: 1g + vg: + vg1: + name: vg_data + enabled: True # default True + devices: + - /dev/sdb + - /dev/sdc + options: + physicalextentsize: 1g + vg_data2: + devices: + - /dev/sdd + pv: + pv1: + enabled: True # False to remove it + device: /dev/sdb + options: + setphysicalvolumesize: 2g + /dev/sdc: + enabled: True + options: + whatever_pvcreate_option: value + /dev/sdd: + enabled: True From 8eb8a482654522061df04c7646dd7655baf85c0d Mon Sep 17 00:00:00 2001 From: N Date: Sat, 21 Sep 2019 18:57:25 +0100 Subject: [PATCH 04/10] feat(lint): add yamllint file --- lvm/.yamllint | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lvm/.yamllint diff --git a/lvm/.yamllint b/lvm/.yamllint new file mode 100644 index 0000000..a8509bc --- /dev/null +++ b/lvm/.yamllint @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- +# Extend the `default` configuration provided by `yamllint` +extends: default + +# Files to ignore completely +# 1. All YAML files under directory `node_modules/`, introduced during the Travis run +# 2. Any SLS files under directory `test/`, which are actually state files +ignore: | + node_modules/ + test/**/states/**/*.sls + +yaml-files: + # Default settings + - '*.yaml' + - '*.yml' + - .yamllint + # SaltStack Formulas additional settings + - '*.example' + - test/**/*.sls + +rules: + empty-values: + forbid-in-block-mappings: true + forbid-in-flow-mappings: true + line-length: + # Increase from default of `80` + # Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`) + max: 88 From 0ecb72426b3c176a19444afcf2b4d9e4cd57309f Mon Sep 17 00:00:00 2001 From: N Date: Sat, 21 Sep 2019 19:13:47 +0100 Subject: [PATCH 05/10] test(kitchen): add bin/kitchen --- bin/kitchen | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 bin/kitchen diff --git a/bin/kitchen b/bin/kitchen new file mode 100755 index 0000000..1cd44f3 --- /dev/null +++ b/bin/kitchen @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'kitchen' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("test-kitchen", "kitchen") From 50f235b6ddcccffd21535a0a61ee6fa07ace18c2 Mon Sep 17 00:00:00 2001 From: N Date: Sat, 21 Sep 2019 19:18:43 +0100 Subject: [PATCH 06/10] test(kitchen): add gemfile --- Gemfile | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Gemfile diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..3b36de3 --- /dev/null +++ b/Gemfile @@ -0,0 +1,6 @@ +source "https://rubygems.org" + +gem 'kitchen-docker', '>= 2.9' +gem 'kitchen-salt', '>= 0.6.0' +gem 'kitchen-inspec', '>= 1.1' + From 47e584348edeeccf91aa3fd00bd816e3174923c0 Mon Sep 17 00:00:00 2001 From: N Date: Sat, 21 Sep 2019 19:25:50 +0100 Subject: [PATCH 07/10] docs(example): updated pillar.example --- lvm/map.jinja | 8 - lvm/osfamilymap.yaml | 5 +- pillar.example | 55 +----- test/salt/pillar/pillar.example | 306 +------------------------------- 4 files changed, 13 insertions(+), 361 deletions(-) diff --git a/lvm/map.jinja b/lvm/map.jinja index c02bc51..2dc2bc5 100644 --- a/lvm/map.jinja +++ b/lvm/map.jinja @@ -54,11 +54,3 @@ {%- set macos_group = salt['cmd.run']("stat -f '%Sg' /dev/console") %} {%- do lvm.update({'rootgroup': macos_group}) %} {%- endif %} - - -## legacy remove in future ## -{% set os_family_map = salt['grains.filter_by']({ - 'RedHat': { 'pkg': 'lvm2', }, - 'Debian': { 'pkg': 'lvm2', }, - }, merge=salt['config.get']('lvm:lookup')) %} -{% set lvm_settings = salt['config.get']( 'lvm', default=os_family_map, merge=True) %} diff --git a/lvm/osfamilymap.yaml b/lvm/osfamilymap.yaml index 8335600..9f5af64 100644 --- a/lvm/osfamilymap.yaml +++ b/lvm/osfamilymap.yaml @@ -11,9 +11,10 @@ # osfamilymap: {} --- Debian: - kmodules: - - dm_thin_pool + #modules: + # dm_thin_pool pkgs: + - lvm2 - thin-provisioning-tools RedHat: diff --git a/pillar.example b/pillar.example index 5d4f009..62b53cf 100644 --- a/pillar.example +++ b/pillar.example @@ -1,11 +1,6 @@ # vim: sts=2 ts=2 sw= et ai # -# for legacy pillar support (backward compatibility) see bottom of file - lvm: - pkg: lvm2 - group: root - config: dir: profiles: /etc/lvm/profile @@ -39,11 +34,6 @@ lvm: losetup: #setup loop devices. todo: could be 'list' instead. /tmp/loopdevs/testfile1.img: {} /tmp/loopdevs/testfile2.img: {} - pv: - create: - /dev/loop0: #hopefully /tmp/loopdevs/testfile1.img - /dev/loop1: #hopefully /tmp/loopdevs/testfile2.img - pv: remove: /tmp/loopdevs/loopback1: @@ -80,6 +70,8 @@ lvm: #name: vg00/lv1 noudevsync: True create: + /dev/loop0: #hopefully /tmp/loopdevs/testfile1.img + /dev/loop1: #hopefully /tmp/loopdevs/testfile2.img /dev/sdb: /dev/sdc: options: @@ -354,46 +346,3 @@ lvm: mount: True onboot: True onboot_opts: - -### LEGACY PILLAR SUPPORT ### - -lvm: - lv: - lv1: - name: lv_data1 - vgname: vg_data - options: - size: 1g - stripes: 5 - stripesize: 8K - thinpool: True - thinvolume: True - lv_data2: - enabled: False # this lv will be removed - vgname: vg_data2 - options: - size: 1g - vg: - vg1: - name: vg_data - enabled: True # default True - devices: - - /dev/sdb - - /dev/sdc - options: - physicalextentsize: 1g - vg_data2: - devices: - - /dev/sdd - pv: - pv1: - enabled: True # False to remove it - device: /dev/sdb - options: - setphysicalvolumesize: 2g - /dev/sdc: - enabled: True - options: - whatever_pvcreate_option: value - /dev/sdd: - enabled: True diff --git a/test/salt/pillar/pillar.example b/test/salt/pillar/pillar.example index 5d4f009..156a061 100644 --- a/test/salt/pillar/pillar.example +++ b/test/salt/pillar/pillar.example @@ -1,11 +1,6 @@ # vim: sts=2 ts=2 sw= et ai # -# for legacy pillar support (backward compatibility) see bottom of file - lvm: - pkg: lvm2 - group: root - config: dir: profiles: /etc/lvm/profile @@ -39,59 +34,31 @@ lvm: losetup: #setup loop devices. todo: could be 'list' instead. /tmp/loopdevs/testfile1.img: {} /tmp/loopdevs/testfile2.img: {} - pv: - create: - /dev/loop0: #hopefully /tmp/loopdevs/testfile1.img - /dev/loop1: #hopefully /tmp/loopdevs/testfile2.img - pv: remove: - /tmp/loopdevs/loopback1: + /dev/loop4: options: verbose: True loopback: size: 10G encryption: none - /dev/sdb: - options: - verbose: True - /dev/sdc: - options: - debug: True - /dev/sdd: - /dev/sde: - /dev/sdf: + /dev/loop5: change: ##Named PV must belong to VG; i.e. PV must be allocatable - /dev/sdd: + /dev/loop4: options: addtag: 'goodpvs' deltag: 'badpvs' debug: 1 resize: - /dev/sdd: + /dev/loop4: options: setphysicalvolumesize: 1G - move: - ##(Named LV and) old PV must be in same VG; i.e. PVs must be allocatable - /dev/sdd: - dest: /dev/sde - options: - #name: vg00/lv1 - noudevsync: True create: - /dev/sdb: - /dev/sdc: + /dev/loop4: #hopefully /tmp/loopdevs/testfile1.img + /dev/loop5: #hopefully /tmp/loopdevs/testfile2.img options: verbose: True - /dev/sdd: - /dev/sde: - options: - override: True - dataalignmentoffset: 7s - metadatacopies: 1 - metadatasize: 40MiB - /dev/sdf: vg: cfgbackup: @@ -100,19 +67,6 @@ lvm: options: quiet: True - import: - i_do_not_exist: - options: - verbose: True - - remove: - vg00: - options: - noudevsync: True - vg_large: - options: - noudevsync: True - change: vg00: options: @@ -120,123 +74,22 @@ lvm: syncronize: False addtag: 'goodvgs' deltag: 'badvgs' - - reduce: - vg00: - devices: - - /dev/sdb - options: - removemissing: True - - extend: - vg00: - devices: - - /dev/sdd - options: - restoremissing: True - - split: - vg00: - newvg: smallvg - devices: - - /dev/sdf - options: - clustered: n - maxphysicalvolumes: 0 - maxlogicalvolumes: 0 - - merge: - vg00: - withvg: vg001 - options: - debug: True - - rename: - vg002: - newname: vg2 - options: - debug: True - create: vg00: devices: - - /dev/sdb - - /dev/sdc + - /dev/loop4 + - /dev/loop5 options: clustered: n maxlogicalvolumes: 0 maxphysicalvolumes: 0 physicalextentsize: 1024 - vg_large: - devices: - - /dev/sdd - - /dev/sde - - /dev/sdf - - export: - vg_tmp: - options: - verbose: True - commandprofile: command_profile_template cfgrestore: vg00: file: vg00_backup_today lv: - remove: - lv_pool1: - vgname: vg_large - lv_pool1_meta: - vgname: vg_large - lvol0: - vgname: vg_large - lvol1: - vgname: vg_large - lvol2: - vgname: vg_large - lvol3: - vgname: vg_large - lvol4: - vgname: vg_large - lvol5: - vgname: vg_large - lvol6: - vgname: vg_large - my_raid1: - vgname: vg_large - options: - force: True - - change: - vg00/lv1: - options: - permission: r - activate: n - addtag: 'goodlvs' - deltag: 'badlvs' - - reduce: - vg00/lv1: - options: - extents: -2 - vg00/lv2: - options: - size: -20MiB - - extend: - vg00/lv1: - options: - #extents: +100%PVS - extents: 2 - devices: - - /dev/sdf - - rename: - vg00/lv11: - vgname: vg00 - newname: lvolvo - create: lv1: vgname: vg00 @@ -245,106 +98,6 @@ lvm: addtag: 'Coolvolume' contiguous: y monitor: y - lv_stripe1: - vgname: vg00 - options: - extents: 1 - stripes: 2 - stripesize: 4096 - #following pillars support snapshots: see https://github.com/saltstack/salt/issues/48808 - sparse: - vgname: vg00 - snapshot: True - sourcelv: lv1 - options: - size: 200MiB - lv2_snap: - vgname: vg00 - snapshot: True - sourcelv: lv2 - options: - size: '+10%ORIGIN' - devices: - - /dev/sdc:0-7 - - /dev/sdd:0-7 - # untested ... - lv_raid5: - vgname: vg00 - size: 5MiB - options: - type: raid5 - stripes: 3 - stripesize: 64 - #lv_raid10_a: - # vgname: vg00 - # options: - # type: raid10 - # size: 5MiB - # stripes: 2 - # mirrors: 1 - - # data logical volume for thinLV - lv_pool1: - vgname: vg_large - size: 1G - devices: - - /dev/sdd:0-7 - # thin metadata logical volume for thinLV - lv_pool1_meta: - vgname: vg_large - size: 50MiB - devices: - - /dev/sdd:0-7 - # thin LV - lv_thin1: - vgname: lv_thinpool1 - thinvolume: True - size: 50M - options: - virtualsize: 1G - lv_raid10_b: - vgname: vg_large - size: 100MiB - options: - stripes: 2 - stripesize: 64 - chunksize: 256 - thin: True #thinlogicalvolume - thinpool: lv_pool1 - virtualsize: 1G - background: True - - convert: - ##thin pool logical volume - vg_large/lv_thinpool1: - options: - type: thin-pool - ##data and metadata LVs in a thin pool are best created on separate physical devices - poolmetadata: - - lv_pool1_meta - - lv_pool1 - vg_large/lv_pool1: - options: - type: thin-pool - vg_large/lv_1: - options: - mirrors: 1 - mirrorlog: core - devices: - - /dev/sdd:0-15 - - /dev/sdd:0-15 - vg_large/lv_mirror1: - options: - splitmirrors: 1 - name: lv_split - regionsize: 512KB - background: False - interval: 10 - noudevsync: False - devices: - - /dev/sde - - /dev/sdf - filesystems: create: /dev/vg00/lv1: @@ -354,46 +107,3 @@ lvm: mount: True onboot: True onboot_opts: - -### LEGACY PILLAR SUPPORT ### - -lvm: - lv: - lv1: - name: lv_data1 - vgname: vg_data - options: - size: 1g - stripes: 5 - stripesize: 8K - thinpool: True - thinvolume: True - lv_data2: - enabled: False # this lv will be removed - vgname: vg_data2 - options: - size: 1g - vg: - vg1: - name: vg_data - enabled: True # default True - devices: - - /dev/sdb - - /dev/sdc - options: - physicalextentsize: 1g - vg_data2: - devices: - - /dev/sdd - pv: - pv1: - enabled: True # False to remove it - device: /dev/sdb - options: - setphysicalvolumesize: 2g - /dev/sdc: - enabled: True - options: - whatever_pvcreate_option: value - /dev/sdd: - enabled: True From 7ce18d8c464dc98c5ed0420904f5612972f49c14 Mon Sep 17 00:00:00 2001 From: N Date: Sat, 21 Sep 2019 21:14:36 +0100 Subject: [PATCH 08/10] fix(pillardata): clustered=>shared; fix yamllint issues --- lvm/.yamllint => .yamllint | 0 README.rst | 4 +- commitlint.config.js | 3 + lvm/defaults.yaml | 10 +-- lvm/map.jinja | 14 ++-- lvm/oscodename.yaml | 37 ----------- lvm/osfamilymap.yaml | 7 +- lvm/osfingermap.yaml | 4 +- lvm/osmap.yaml | 6 +- pillar.example | 112 ++++++++++++++++---------------- test/salt/pillar/pillar.example | 58 +++++++---------- 11 files changed, 104 insertions(+), 151 deletions(-) rename lvm/.yamllint => .yamllint (100%) create mode 100644 commitlint.config.js delete mode 100644 lvm/oscodename.yaml diff --git a/lvm/.yamllint b/.yamllint similarity index 100% rename from lvm/.yamllint rename to .yamllint diff --git a/README.rst b/README.rst index e920a5e..e932e56 100644 --- a/README.rst +++ b/README.rst @@ -280,7 +280,7 @@ Split volume group(s) into two:: devices: - /dev/sdf options: - clustered: n + shared: n maxphysicalvolumes: 0 maxlogicalvolumes: 0 @@ -313,7 +313,7 @@ Create volume group(s):: - /dev/sdb - /dev/sdc options: - clustered: n + shared: n maxlogicalvolumes: 0 maxphysicalvolumes: 0 physicalextentsize: 1024 diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000..2f9d1aa --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,3 @@ +module.exports = { + extends: ['@commitlint/config-conventional'], +}; diff --git a/lvm/defaults.yaml b/lvm/defaults.yaml index 60dda6b..717f034 100644 --- a/lvm/defaults.yaml +++ b/lvm/defaults.yaml @@ -1,5 +1,6 @@ # vim: sts=2 ts=2 sw= et ai # +--- lvm: pkgs: - lvm2 @@ -26,11 +27,10 @@ lvm: vendor: kernel format: div: "=" - ucl: False - json: False + ucl: false + json: false vg: - enable_export: False - enable_cfgrestore: False + enable_export: false + enable_cfgrestore: false pv: {} lv: {} - diff --git a/lvm/map.jinja b/lvm/map.jinja index 2dc2bc5..c84acd2 100644 --- a/lvm/map.jinja +++ b/lvm/map.jinja @@ -7,10 +7,8 @@ {%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %} {%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %} {%- import_yaml tplroot ~ "/osmap.yaml" as osmap %} -{%- import_yaml tplroot ~ "/oscodename.yaml" as oscodename %} {%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %} - {#- Retrieve the config dict only once #} {%- set _config = salt['config.get'](tplroot, default={}) %} @@ -24,15 +22,11 @@ osmap, grain='os', merge=salt['grains.filter_by']( - oscodename, - grain='oscodename', + osfingermap, + grain='osfinger', merge=salt['grains.filter_by']( - osfingermap, - grain='osfinger', - merge=salt['grains.filter_by']( - _config, - default='lookup' - ) + _config, + default='lookup' ) ) ) diff --git a/lvm/oscodename.yaml b/lvm/oscodename.yaml deleted file mode 100644 index f920e35..0000000 --- a/lvm/oscodename.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: ft=yaml -# -{% macro debian_codename(name, codename=none) %} -{{ codename|default(name, true) }}: -{% endmacro %} - -{% macro fedora_codename(name, release, codename) %} -{{ codename|default(name, true) }}: -{% endmacro %} - -## Debian GNU/Linux -{{ debian_codename('wheezy') }} -{{ debian_codename('jessie') }} -{{ debian_codename('stretch') }} -{{ debian_codename('buster') }} -{{ debian_codename('bullseye') }} - - ## `oscodename` is longname if `lsb-release` not installed -{{ debian_codename('wheezy', 'Debian GNU/Linux 7 (wheezy)') }} -{{ debian_codename('jessie', 'Debian GNU/Linux 8 (jessie)') }} -{{ debian_codename('stretch', 'Debian GNU/Linux 9 (stretch)') }} -{{ debian_codename('buster', 'Debian GNU/Linux 10 (buster)') }} -{{ debian_codename('bullseye', 'Debian GNU/Linux 11 (bullseye)') }} - -## Ubuntu -{{ debian_codename('trusty', 'trusty') }} -{{ debian_codename('xenial', 'xenial') }} -{{ debian_codename('artful', 'artful') }} -{{ debian_codename('bionic', 'bionic') }} -{{ debian_codename('cosmic', 'cosmic') }} - -## Fedora -# `oscodename` grain has long distro name -{{ fedora_codename('Fedora-29', 29, 'Fedora 29 (Twenty Nine)') }} - -# vim: ft=sls diff --git a/lvm/osfamilymap.yaml b/lvm/osfamilymap.yaml index 9f5af64..c8676cb 100644 --- a/lvm/osfamilymap.yaml +++ b/lvm/osfamilymap.yaml @@ -11,8 +11,8 @@ # osfamilymap: {} --- Debian: - #modules: - # dm_thin_pool + # modules: + # dm_thin_pool pkgs: - lvm2 - thin-provisioning-tools @@ -22,7 +22,6 @@ RedHat: - lvm2 - cryptsetup - device-mapper-persistent-data - - thin-provisioning-tools profiles: default: thin-generic: {} @@ -33,6 +32,7 @@ RedHat: Arch: pkgs: + - lvm2 - thin-provisioning-tools OpenBSD: @@ -40,6 +40,7 @@ OpenBSD: Suse: pkgs: + - lvm2 - thin-provisioning-tools Gentoo: {} diff --git a/lvm/osfingermap.yaml b/lvm/osfingermap.yaml index 0d24c45..cb07b06 100644 --- a/lvm/osfingermap.yaml +++ b/lvm/osfingermap.yaml @@ -17,8 +17,8 @@ CentOS-6: CentOS-7: pkgs: - - device-mapper-persistent-data #aka thin-provisioning-tools + - device-mapper-persistent-data # was thin-provisioning-tools CentOS-8: pkgs: - - device-mapper-persistent-data #aka thin-provisioning-tools + - device-mapper-persistent-data # was thin-provisioning-tools diff --git a/lvm/osmap.yaml b/lvm/osmap.yaml index 0a2664c..3a82214 100644 --- a/lvm/osmap.yaml +++ b/lvm/osmap.yaml @@ -13,9 +13,11 @@ # os_family: RedHat Fedora: pkgs: - - device-mapper-persistent-data #aka thin-provisioning-tools + - lvm2 + - device-mapper-persistent-data # was thin-provisioning-tools # os_family: RedHat Amazon: pkgs: - - device-mapper-persistent-data #aka thin-provisioning-tools + - lvm2 + - device-mapper-persistent-data # was thin-provisioning-tools diff --git a/pillar.example b/pillar.example index 62b53cf..fef644b 100644 --- a/pillar.example +++ b/pillar.example @@ -1,5 +1,6 @@ # vim: sts=2 ts=2 sw= et ai # +--- lvm: config: dir: @@ -16,43 +17,43 @@ lvm: thin_pool_autoextend_percent: 20 files: - #loopbackdir: /tmp/loopdevs #Where to create backing files? + # loopbackdir: /tmp/loopdevs # Where to create backing files? remove: - /tmp/loopdevs/testfile1.img - /tmp/loopdevs/testfile2.img create: - truncate: #Shrink or extend the size of each FILE to the specified size + truncate: # Shrink or extend the size of each FILE to the specified size testfile1.img: options: size: 100M - dd: #copy a file, converting and formatting according to the operands + dd: # copy a file, converting and formatting according to the operands /tmp/loopdevs/testfile2.img: options: if: /dev/urandom bs: 1024 count: 204800 - losetup: #setup loop devices. todo: could be 'list' instead. + losetup: # setup loop devices. todo: could be 'list' instead. /tmp/loopdevs/testfile1.img: {} /tmp/loopdevs/testfile2.img: {} pv: remove: /tmp/loopdevs/loopback1: options: - verbose: True + verbose: true loopback: size: 10G encryption: none /dev/sdb: options: - verbose: True + verbose: true /dev/sdc: options: - debug: True - /dev/sdd: - /dev/sde: - /dev/sdf: + debug: true + /dev/sdd: {} + /dev/sde: {} + /dev/sdf: {} change: - ##Named PV must belong to VG; i.e. PV must be allocatable + # Named PV must belong to VG; i.e. PV must be allocatable /dev/sdd: options: addtag: 'goodpvs' @@ -63,53 +64,53 @@ lvm: options: setphysicalvolumesize: 1G move: - ##(Named LV and) old PV must be in same VG; i.e. PVs must be allocatable + # (Named LV and) old PV must be in same VG; i.e. PVs must be allocatable /dev/sdd: dest: /dev/sde options: - #name: vg00/lv1 - noudevsync: True + # name: vg00/lv1 + noudevsync: true create: - /dev/loop0: #hopefully /tmp/loopdevs/testfile1.img - /dev/loop1: #hopefully /tmp/loopdevs/testfile2.img - /dev/sdb: + /dev/loop0: {} # hopefully /tmp/loopdevs/testfile1.img + /dev/loop1: {} # hopefully /tmp/loopdevs/testfile2.img + /dev/sdb: {} /dev/sdc: options: - verbose: True - /dev/sdd: + verbose: true + /dev/sdd: {} /dev/sde: options: - override: True + override: true dataalignmentoffset: 7s metadatacopies: 1 metadatasize: 40MiB - /dev/sdf: + /dev/sdf: {} vg: cfgbackup: vg00: file: vg00_backup_today options: - quiet: True + quiet: true import: i_do_not_exist: options: - verbose: True + verbose: true remove: vg00: options: - noudevsync: True + noudevsync: true vg_large: options: - noudevsync: True + noudevsync: true change: vg00: options: - available: True - syncronize: False + available: true + syncronize: false addtag: 'goodvgs' deltag: 'badvgs' @@ -118,14 +119,14 @@ lvm: devices: - /dev/sdb options: - removemissing: True + removemissing: true extend: vg00: devices: - /dev/sdd options: - restoremissing: True + restoremissing: true split: vg00: @@ -141,13 +142,13 @@ lvm: vg00: withvg: vg001 options: - debug: True + debug: true rename: vg002: newname: vg2 options: - debug: True + debug: true create: vg00: @@ -168,7 +169,7 @@ lvm: export: vg_tmp: options: - verbose: True + verbose: true commandprofile: command_profile_template cfgrestore: @@ -198,7 +199,7 @@ lvm: my_raid1: vgname: vg_large options: - force: True + force: true change: vg00/lv1: @@ -219,7 +220,7 @@ lvm: extend: vg00/lv1: options: - #extents: +100%PVS + # extents: +100%PVS extents: 2 devices: - /dev/sdf @@ -243,16 +244,16 @@ lvm: extents: 1 stripes: 2 stripesize: 4096 - #following pillars support snapshots: see https://github.com/saltstack/salt/issues/48808 + # snapshots: see https://github.com/saltstack/salt/issues/48808 sparse: vgname: vg00 - snapshot: True + snapshot: true sourcelv: lv1 options: size: 200MiB lv2_snap: vgname: vg00 - snapshot: True + snapshot: true sourcelv: lv2 options: size: '+10%ORIGIN' @@ -267,13 +268,13 @@ lvm: type: raid5 stripes: 3 stripesize: 64 - #lv_raid10_a: - # vgname: vg00 - # options: - # type: raid10 - # size: 5MiB - # stripes: 2 - # mirrors: 1 + # lv_raid10_a: + # vgname: vg00 + # options: + # type: raid10 + # size: 5MiB + # stripes: 2 + # mirrors: 1 # data logical volume for thinLV lv_pool1: @@ -290,7 +291,7 @@ lvm: # thin LV lv_thin1: vgname: lv_thinpool1 - thinvolume: True + thinvolume: true size: 50M options: virtualsize: 1G @@ -301,17 +302,18 @@ lvm: stripes: 2 stripesize: 64 chunksize: 256 - thin: True #thinlogicalvolume + thin: true # thinlogicalvolume thinpool: lv_pool1 virtualsize: 1G - background: True - + background: true + convert: - ##thin pool logical volume + # thin pool logical volume vg_large/lv_thinpool1: options: type: thin-pool - ##data and metadata LVs in a thin pool are best created on separate physical devices + # data & metadata LVs in thin pool are best + # created on separate physical devices poolmetadata: - lv_pool1_meta - lv_pool1 @@ -330,9 +332,9 @@ lvm: splitmirrors: 1 name: lv_split regionsize: 512KB - background: False + background: false interval: 10 - noudevsync: False + noudevsync: false devices: - /dev/sde - /dev/sdf @@ -343,6 +345,6 @@ lvm: options: type: gfs options: '-plock_nolock -j 1' - mount: True - onboot: True - onboot_opts: + mount: true + onboot: true + onboot_opts: {} diff --git a/test/salt/pillar/pillar.example b/test/salt/pillar/pillar.example index 156a061..863a08d 100644 --- a/test/salt/pillar/pillar.example +++ b/test/salt/pillar/pillar.example @@ -1,5 +1,6 @@ # vim: sts=2 ts=2 sw= et ai # +--- lvm: config: dir: @@ -16,74 +17,61 @@ lvm: thin_pool_autoextend_percent: 20 files: - #loopbackdir: /tmp/loopdevs #Where to create backing files? + # loopbackdir: /tmp/loopdevs # for backing files remove: - /tmp/loopdevs/testfile1.img - /tmp/loopdevs/testfile2.img create: - truncate: #Shrink or extend the size of each FILE to the specified size + truncate: # Shrink or extend the size of each FILE to the specified size testfile1.img: options: size: 100M - dd: #copy a file, converting and formatting according to the operands + dd: # copy a file, converting and formatting according to the operands /tmp/loopdevs/testfile2.img: options: if: /dev/urandom bs: 1024 count: 204800 - losetup: #setup loop devices. todo: could be 'list' instead. + losetup: # setup loop devices. todo: could be 'list' instead. /tmp/loopdevs/testfile1.img: {} /tmp/loopdevs/testfile2.img: {} pv: remove: /dev/loop4: options: - verbose: True - loopback: - size: 10G - encryption: none - /dev/loop5: + verbose: true + /dev/loop5: {} + change: - ##Named PV must belong to VG; i.e. PV must be allocatable + # Named PV must belong to VG; i.e. PV must be allocatable /dev/loop4: options: addtag: 'goodpvs' deltag: 'badpvs' debug: 1 - resize: - /dev/loop4: - options: - setphysicalvolumesize: 1G + create: - /dev/loop4: #hopefully /tmp/loopdevs/testfile1.img - /dev/loop5: #hopefully /tmp/loopdevs/testfile2.img + /dev/loop4: {} # hopefully /tmp/loopdevs/testfile1.img + /dev/loop5: # hopefully /tmp/loopdevs/testfile2.img options: - verbose: True + verbose: true vg: cfgbackup: vg00: file: vg00_backup_today options: - quiet: True - - change: - vg00: - options: - available: True - syncronize: False - addtag: 'goodvgs' - deltag: 'badvgs' + quiet: true create: vg00: devices: - /dev/loop4 - /dev/loop5 options: - clustered: n + shared: n maxlogicalvolumes: 0 maxphysicalvolumes: 0 - physicalextentsize: 1024 + # physicalextentsize: 1024 cfgrestore: vg00: @@ -93,17 +81,17 @@ lvm: create: lv1: vgname: vg00 - size: 200MiB + size: 150MiB options: + zero: n addtag: 'Coolvolume' - contiguous: y - monitor: y + filesystems: create: /dev/vg00/lv1: options: - type: gfs + type: xfs options: '-plock_nolock -j 1' - mount: True - onboot: True - onboot_opts: + mount: true + onboot: true + onboot_opts: {} From 454f0a1a5b9d52fe19009298ffc4f1f56fd3afca Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Mon, 23 Sep 2019 19:55:46 +0100 Subject: [PATCH 09/10] feat(semantic-release): implement for this formula * Checked using https://github.com/myii/ssf-formula/pull/42 --- .gitignore | 122 ++++++++++++++++++ .travis.yml | 22 ++-- FORMULA | 9 ++ docs/CONTRIBUTING.rst | 159 +++++++++++++++++++++++ README.rst => docs/README.rst | 192 ++++++++++++++++++++-------- kitchen.yml | 25 +++- pre-commit_semantic-release.sh | 30 +++++ release-rules.js | 18 +++ release.config.js | 106 +++++++++++++++ test/integration/default/inspec.yml | 1 + 10 files changed, 614 insertions(+), 70 deletions(-) create mode 100644 .gitignore create mode 100644 FORMULA create mode 100644 docs/CONTRIBUTING.rst rename README.rst => docs/README.rst (74%) create mode 100755 pre-commit_semantic-release.sh create mode 100644 release-rules.js create mode 100644 release.config.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0bbb03c --- /dev/null +++ b/.gitignore @@ -0,0 +1,122 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a packager +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.kitchen +.kitchen.local.yml +kitchen.local.yml +junit-*.xml + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# Bundler +Gemfile.lock + +# copied `.md` files used for conversion to `.rst` using `m2r` +docs/*.md + +# Vim +*.sw? + +## Collected when centralising formulas (check and sort) +# `collectd-formula` +.pytest_cache/ +/.idea/ +Dockerfile.*_* +ignore/ +tmp/ diff --git a/.travis.yml b/.travis.yml index 2e1631f..fd71fca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,27 +22,31 @@ env: - INSTANCE: default-debian-10-develop-py3 # - INSTANCE: default-ubuntu-1804-develop-py3 # - INSTANCE: default-centos-7-develop-py3 - - INSTANCE: default-fedora-30-develop-py3 + # - INSTANCE: default-fedora-30-develop-py3 # - INSTANCE: default-opensuse-leap-15-develop-py3 # - INSTANCE: default-amazonlinux-2-develop-py2 + # - INSTANCE: default-arch-base-latest-develop-py2 # - INSTANCE: default-debian-9-2019-2-py3 - INSTANCE: default-ubuntu-1804-2019-2-py3 - - INSTANCE: default-centos-7-2019-2-py3 - # - INSTANCE: default-fedora-30-2019-2-py3 + # - INSTANCE: default-centos-7-2019-2-py3 + - INSTANCE: default-fedora-30-2019-2-py3 # - INSTANCE: default-opensuse-leap-15-2019-2-py3 - # INSTANCE: default-amazonlinux-2-2019-2-py2 + # - INSTANCE: default-amazonlinux-2-2019-2-py2 + # - INSTANCE: default-arch-base-latest-2019-2-py2 # - INSTANCE: default-debian-9-2018-3-py2 # - INSTANCE: default-ubuntu-1604-2018-3-py2 - # INSTANCE: default-centos-7-2018-3-py2 - # INSTANCE: default-fedora-29-2018-3-py2 + - INSTANCE: default-centos-7-2018-3-py2 + # - INSTANCE: default-fedora-29-2018-3-py2 - INSTANCE: default-opensuse-leap-15-2018-3-py2 - - INSTANCE: default-amazonlinux-2-2018-3-py2 + # - INSTANCE: default-amazonlinux-2-2018-3-py2 + # - INSTANCE: default-arch-base-latest-2018-3-py2 # - INSTANCE: default-debian-8-2017-7-py2 # - INSTANCE: default-ubuntu-1604-2017-7-py2 - # INSTANCE: default-centos-6-2017-7-py2 + # - INSTANCE: default-centos-6-2017-7-py2 # - INSTANCE: default-fedora-29-2017-7-py2 # - INSTANCE: default-opensuse-leap-15-2017-7-py2 - # - INSTANCE: default-amazonlinux-2-2017-7-py2 + - INSTANCE: default-amazonlinux-2-2017-7-py2 + # - INSTANCE: default-arch-base-latest-2017-7-py2 script: - bin/kitchen verify ${INSTANCE} diff --git a/FORMULA b/FORMULA new file mode 100644 index 0000000..2db60c4 --- /dev/null +++ b/FORMULA @@ -0,0 +1,9 @@ +name: lvm +os: Debian, Ubuntu, Raspbian, RedHat, Fedora, CentOS, Suse, openSUSE, Gentoo, Funtoo, Arch, Manjaro, Alpine, FreeBSD, OpenBSD, Solaris, SmartOS, Windows, MacOS +os_family: Debian, RedHat, Suse, Gentoo, Arch, Alpine, FreeBSD, OpenBSD, Solaris, Windows, MacOS +version: 0.2.4 +release: 1 +minimum_version: 2017.7 +summary: lvm formula +description: Formula to install and configure Linux logical volume management (LVM2) +top_level_dir: lvm diff --git a/docs/CONTRIBUTING.rst b/docs/CONTRIBUTING.rst new file mode 100644 index 0000000..b7da8f4 --- /dev/null +++ b/docs/CONTRIBUTING.rst @@ -0,0 +1,159 @@ +.. _contributing: + +How to contribute +================= + +This document will eventually outline all aspects of guidance to make your contributing experience a fruitful and enjoyable one. +What it already contains is information about *commit message formatting* and how that directly affects the numerous automated processes that are used for this repo. +It also covers how to contribute to this *formula's documentation*. + +.. contents:: **Table of Contents** + +Overview +-------- + +Submitting a pull request is more than just code! +To achieve a quality product, the *tests* and *documentation* need to be updated as well. +An excellent pull request will include these in the changes, wherever relevant. + +Commit message formatting +------------------------- + +Since every type of change requires making Git commits, +we will start by covering the importance of ensuring that all of your commit +messages are in the correct format. + +Automation of multiple processes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This formula uses `semantic-release `_ for automating numerous processes such as bumping the version number appropriately, creating new tags/releases and updating the changelog. +The entire process relies on the structure of commit messages to determine the version bump, which is then used for the rest of the automation. + +Full details are available in the upstream docs regarding the `Angular Commit Message Conventions `_. +The key factor is that the first line of the commit message must follow this format: + +.. code-block:: + + type(scope): subject + + +* E.g. ``docs(contributing): add commit message formatting instructions``. + +Besides the version bump, the changelog and release notes are formatted accordingly. +So based on the example above: + +.. + + .. raw:: html + +

Documentation

+ + * **contributing:** add commit message formatting instructions + + +* The ``type`` translates into a ``Documentation`` sub-heading. +* The ``(scope):`` will be shown in bold text without the brackets. +* The ``subject`` follows the ``scope`` as standard text. + +Linting commit messages in Travis CI +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This formula uses `commitlint `_ for checking commit messages during CI testing. +This ensures that they are in accordance with the ``semantic-release`` settings. + +For more details about the default settings, refer back to the ``commitlint`` `reference rules `_. + +Relationship between commit type and version bump +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This formula applies some customisations to the defaults, as outlined in the table below, +based upon the `type `_ of the commit: + +.. list-table:: + :name: commit-type-vs-version-bump + :header-rows: 1 + :stub-columns: 0 + :widths: 1,2,3,1,1 + + * - Type + - Heading + - Description + - Bump (default) + - Bump (custom) + * - ``build`` + - Build System + - Changes related to the build system + - – + - + * - ``chore`` + - – + - Changes to the build process or auxiliary tools and libraries such as + documentation generation + - – + - + * - ``ci`` + - Continuous Integration + - Changes to the continuous integration configuration + - – + - + * - ``docs`` + - Documentation + - Documentation only changes + - – + - 0.0.1 + * - ``feat`` + - Features + - A new feature + - 0.1.0 + - + * - ``fix`` + - Bug Fixes + - A bug fix + - 0.0.1 + - + * - ``perf`` + - Performance Improvements + - A code change that improves performance + - 0.0.1 + - + * - ``refactor`` + - Code Refactoring + - A code change that neither fixes a bug nor adds a feature + - – + - 0.0.1 + * - ``revert`` + - Reverts + - A commit used to revert a previous commit + - – + - 0.0.1 + * - ``style`` + - Styles + - Changes that do not affect the meaning of the code (white-space, + formatting, missing semi-colons, etc.) + - – + - 0.0.1 + * - ``test`` + - Tests + - Adding missing or correcting existing tests + - – + - 0.0.1 + +Use ``BREAKING CHANGE`` to trigger a ``major`` version change +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Adding ``BREAKING CHANGE`` to the footer of the extended description of the commit message will **always** trigger a ``major`` version change, no matter which type has been used. +This will be appended to the changelog and release notes as well. +To preserve good formatting of these notes, the following format is prescribed: + +* ``BREAKING CHANGE: .`` + +An example of that: + +.. code-block:: git + + ... + + BREAKING CHANGE: With the removal of all of the `.sls` files under + `template package`, this formula no longer supports the installation of + packages. + diff --git a/README.rst b/docs/README.rst similarity index 74% rename from README.rst rename to docs/README.rst index e932e56..4af9cad 100644 --- a/README.rst +++ b/docs/README.rst @@ -1,57 +1,104 @@ -=========== +.. _readme: + lvm-formula =========== +|img_travis| |img_sr| + +.. |img_travis| image:: https://travis-ci.com/saltstack-formulas/lvm-formula.svg?branch=master + :alt: Travis CI Build Status + :scale: 100% + :target: https://travis-ci.com/saltstack-formulas/lvm-formula +.. |img_sr| image:: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg + :alt: Semantic Release + :scale: 100% + :target: https://github.com/semantic-release/semantic-release + Linux logical volume management (LVM2) state API. note:: The `lvm.conf(5)` is indirectly managed via LVM profiles. -note:: See the full `Salt Formulas installation and usage instructions - `_. +.. contents:: **Table of Contents** + :depth: 1 + +General notes +------------- + +See the full `SaltStack Formulas installation and usage instructions +`_. + +If you are interested in writing or contributing to formulas, please pay attention to the `Writing Formula Section +`_. + +If you want to use this formula, please pay attention to the ``FORMULA`` file and/or ``git tag``, +which contains the currently released version. This formula is versioned according to `Semantic Versioning `_. + +See `Formula Versioning Section `_ for more details. + +Todo +^^^^ +- global filter support is important +- test some advanced LV/RAID scenarios +- file systems mngt + +Good pillar data +^^^^^^^^^^^^^^^^ +Bad configuration causes problems. Sanity check pillar data when troubleshooting "``unable to``" state failures. + +OS families +^^^^^^^^^^^ +All Linux distributions supported. + +Contributing to this repo +------------------------- + +**Commit message formatting is significant!!** + +Please see :ref:`How to contribute ` for more details. Available Meta states -====================== +--------------------- .. contents:: :local: ``lvm`` --------- +^^^^^^^ Meta-state to run all states in sequence: 'install', 'profiles', 'files', 'pv', 'vg', and 'lv'. ``lvm.profiles`` --------------- +^^^^^^^^^^^^^^^^ Meta-state to manage lvm profiles in sequence: 'remove', followed by 'create'. ``lvm.files`` ------------ +^^^^^^^^^^^^^ Meta-state to run loopback file device states in sequence: 'remove', followed by 'create'. Included by `lvm.pv` state. ``lvm.pv`` ------------ +^^^^^^^^^^ Meta-state to run physical volume (PV) states in sequence: 'remove', 'change', 'resize', 'move', and finally 'create'. ``lvm.vg`` --------------- +^^^^^^^^^^ Meta-state to run all volume group states in sequence: 'cfgbackup', 'import', 'remove', 'change' 'reduce', 'extend', 'split', 'merge', 'rename', 'create', 'export' & 'cfgrestore'. ``lvm.lv`` -------------- +^^^^^^^^^^ Meta-state to run all logical volume states in sequence: Order 'remove', 'change', 'reduce', 'extend', 'rename', 'create', 'convert', and 'create' again. Available substates -=================== +------------------- .. contents:: :local: ``lvm.clean`` ------------- +^^^^^^^^^^^^^ Remove lvm2 software. ``lvm.profiles.clean`` ----------------------- +^^^^^^^^^^^^^^^^^^^^^^ Remove custom lvm profile(s):: profiles: @@ -59,19 +106,19 @@ Remove custom lvm profile(s):: - sillyprofile ``lvm.install`` ------------ +^^^^^^^^^^^^^^^ Install lvm2 package. -``lvm.config (depreciated)`` ----------- +``lvm.config (deprecated)`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^ Configure PVs, VGs and LVs using legacy pillar data (backwards compatibility only). ``lvm.clean`` ------------- +^^^^^^^^^^^^^ Remove lvm2 software. ``lvm.profiles.clean`` ----------------------- +^^^^^^^^^^^^^^^^^^^^^^ Remove custom lvm profile(s):: profiles: @@ -79,7 +126,7 @@ Remove custom lvm profile(s):: - sillyprofile ``lvm.profiles.create`` ----------------------- +^^^^^^^^^^^^^^^^^^^^^^^ Create custom lvm profile(s):: lvm: @@ -92,11 +139,11 @@ Create custom lvm profile(s):: ``lvm.files.clean`` ------------------- +^^^^^^^^^^^^^^^^^^^ Remove LVM backing files from the file system. ``lvm.files.create`` ------------------- +^^^^^^^^^^^^^^^^^^^^ LVM Loopback HOW-TO support. Creates backing files (in /tmp by defaults) and loopback devices per pillars:: lvm: @@ -126,7 +173,7 @@ LVM Loopback HOW-TO support. Creates backing files (in /tmp by defaults) and loo ``lvm.pv.clean`` --------------- +^^^^^^^^^^^^^^^^ Remove physical volumes (PVs):: remove: @@ -141,7 +188,7 @@ Remove physical volumes (PVs):: /dev/sdf: ``lvm.pv.change`` --------------- +^^^^^^^^^^^^^^^^^ Change attributes of physical volume(s) (PVs):: pv: @@ -154,7 +201,7 @@ Change attributes of physical volume(s) (PVs):: debug: 1 ``lvm.pv.resize`` --------------- +^^^^^^^^^^^^^^^^^ Resize disk(s) or partition(s) in use by LVM2:: pv: @@ -165,7 +212,7 @@ Resize disk(s) or partition(s) in use by LVM2:: ``lvm.pv.move`` --------------- +^^^^^^^^^^^^^^^ Move allocated physical extents (PEs) from Source PV to other PV(s):: pv: @@ -177,7 +224,7 @@ Move allocated physical extents (PEs) from Source PV to other PV(s):: noudevsync: True ``lvm.pv.create`` --------------- +^^^^^^^^^^^^^^^^^ Initialize disk(s) or partition(s) for use by LVM:: pv: @@ -199,7 +246,7 @@ Initialize disk(s) or partition(s) for use by LVM:: ``lvm.vg.cfgbackup`` -------------------- +^^^^^^^^^^^^^^^^^^^^ Backup the metadata of your volume groups:: vg: @@ -211,7 +258,7 @@ Backup the metadata of your volume groups:: readonly: True ``lvm.vg.import`` --------------- +^^^^^^^^^^^^^^^^^ Make volume groups known to the system:: vg: @@ -221,7 +268,7 @@ Make volume groups known to the system:: verbose: True ``lvm.vg.clean`` --------------- +^^^^^^^^^^^^^^^^ Remove volume group(s):: vg: @@ -231,7 +278,7 @@ Remove volume group(s):: noudevsync: True ``lvm.vg.change`` --------------- +^^^^^^^^^^^^^^^^^ Change attributes of volume group(s):: vg: @@ -245,7 +292,7 @@ Change attributes of volume group(s):: ``lvm.vg.reduce`` --------------- +^^^^^^^^^^^^^^^^^ Remove one or more unused physical volumes from a volume group:: vg: @@ -257,7 +304,7 @@ Remove one or more unused physical volumes from a volume group:: removemissing: True ``lvm.vg.extend`` --------------- +^^^^^^^^^^^^^^^^^ Add physical volumes to a volume group(s):: vg: @@ -270,7 +317,7 @@ Add physical volumes to a volume group(s):: ``lvm.vg.split`` --------------- +^^^^^^^^^^^^^^^^ Split volume group(s) into two:: vg: @@ -285,7 +332,7 @@ Split volume group(s) into two:: maxlogicalvolumes: 0 ``lvm.vg.merge`` --------------- +^^^^^^^^^^^^^^^^ Merge two volume groups:: vg: @@ -294,7 +341,7 @@ Merge two volume groups:: withvg: vg001 ``lvm.vg.rename`` --------------- +^^^^^^^^^^^^^^^^^ Rename volume group(s):: vg: @@ -303,7 +350,7 @@ Rename volume group(s):: newname: vg002old ``lvm.vg.create`` --------------- +^^^^^^^^^^^^^^^^^ Create volume group(s):: vg: @@ -324,7 +371,7 @@ Create volume group(s):: - /dev/sdf ``lvm.vg.export`` --------------- +^^^^^^^^^^^^^^^^^ Make volume groups unknown to the system:: vg: @@ -335,7 +382,7 @@ Make volume groups unknown to the system:: commandprofile: command_profile_template ``lvm.vg.cfgrestore`` -------------------- +^^^^^^^^^^^^^^^^^^^^^ Restore the metadata of VG(s) from text backup files produced by ``lvm.vg.cfgbackup`` state:: vg: @@ -349,7 +396,7 @@ Restore the metadata of VG(s) from text backup files produced by ``lvm.vg.cfgbac ``lvm.lv.clean`` ---------------- +^^^^^^^^^^^^^^^^ Remove LV(s):: lv: @@ -378,7 +425,7 @@ Remove LV(s):: force: True ``lvm.lv.change`` ----------------- +^^^^^^^^^^^^^^^^^ Change attributes of logical volume(s):: lv: @@ -391,7 +438,7 @@ Change attributes of logical volume(s):: deltag: 'badlvs' ``lvm.lv.reduce`` ---------------- +^^^^^^^^^^^^^^^^^ Reduce size of logical volume(s):: lv: @@ -404,7 +451,7 @@ Reduce size of logical volume(s):: size: -20MiB ``lvm.lv.extend`` ----------------- +^^^^^^^^^^^^^^^^^ Extend size of logical volume(s):: lv: @@ -417,7 +464,7 @@ Extend size of logical volume(s):: - /dev/sdf ``lvm.lv.rename`` -------------- +^^^^^^^^^^^^^^^^^ Rename LV(s):: lv: @@ -427,7 +474,7 @@ Rename LV(s):: newname: lvolvo ``lvm.lv.create`` ----------------- +^^^^^^^^^^^^^^^^^ Create logical volume(s) in existing volume group(s):: lv: @@ -463,7 +510,7 @@ Note:: Thin provisioning needs two `create` states to run (`create`, `convert`, ``lvm.lv.convert`` ----------------- +^^^^^^^^^^^^^^^^^^ Change LV type and other utilities:: lv: @@ -494,17 +541,50 @@ Change LV type and other utilities:: Note:: Thin provisioning needs two `create` states to run (`create`, `convert`, and `create`). -Todo -======= -- global filter support is important -- test some advanced LV/RAID scenarios -- file systems mngt +Testing +------- -Good Pillar data -================= -Bad conf(5)iguration causes problems. Sanity check pillar data when troubleshooting "``unable to``" state failures. +.. contents:: + :local: -OS families -================= -All Linux distributions supported. +Linux testing is done with ``kitchen-salt``. + +Requirements +^^^^^^^^^^^^ + +* Ruby +* Docker + +.. code-block:: bash + + $ gem install bundler + $ bundle install + $ bin/kitchen test [platform] + +Where ``[platform]`` is the platform name defined in ``kitchen.yml``, +e.g. ``debian-9-2019-2-py3``. + +``bin/kitchen converge`` +^^^^^^^^^^^^^^^^^^^^^^^^ + +Creates the docker instance and runs the ``lvm`` main state, ready for testing. + +``bin/kitchen verify`` +^^^^^^^^^^^^^^^^^^^^^^ + +Runs the ``inspec`` tests on the actual instance. + +``bin/kitchen destroy`` +^^^^^^^^^^^^^^^^^^^^^^^ + +Removes the docker instance. + +``bin/kitchen test`` +^^^^^^^^^^^^^^^^^^^^ + +Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``. + +``bin/kitchen login`` +^^^^^^^^^^^^^^^^^^^^^ +Gives you SSH access to the instance for manual testing. diff --git a/kitchen.yml b/kitchen.yml index be76fcc..2f65a53 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -53,6 +53,13 @@ platforms: provision_command: - curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com - sh bootstrap-salt.sh -XdPbfrq -x python2 git develop + - name: arch-base-latest-develop-py2 + driver: + image: netmanagers/salt-develop-py2:arch-base-latest + provision_command: + - curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com + - sh bootstrap-salt.sh -XdPbfrq -x python2 git develop + run_command: /usr/lib/systemd/systemd ## SALT `2019.2` - name: debian-9-2019-2-py3 @@ -78,6 +85,10 @@ platforms: - name: amazonlinux-2-2019-2-py2 driver: image: netmanagers/salt-2019.2-py2:amazonlinux-2 + - name: arch-base-latest-2019-2-py2 + driver: + image: netmanagers/salt-2019.2-py2:arch-base-latest + run_command: /usr/lib/systemd/systemd ## SALT `2018.3` - name: debian-9-2018-3-py2 @@ -103,6 +114,10 @@ platforms: - name: amazonlinux-2-2018-3-py2 driver: image: netmanagers/salt-2018.3-py2:amazonlinux-2 + - name: arch-base-latest-2018-3-py2 + driver: + image: netmanagers/salt-2018.3-py2:arch-base-latest + run_command: /usr/lib/systemd/systemd ## SALT `2017.7` - name: debian-8-2017-7-py2 @@ -129,10 +144,14 @@ platforms: - name: amazonlinux-2-2017-7-py2 driver: image: netmanagers/salt-2017.7-py2:amazonlinux-2 + - name: arch-base-latest-2017-7-py2 + driver: + image: netmanagers/salt-2017.7-py2:arch-base-latest + run_command: /usr/lib/systemd/systemd provisioner: name: salt_solo - log_level: info + log_level: debug salt_install: none require_chef: false formula: lvm @@ -151,10 +170,6 @@ verifier: suites: - name: default provisioner: - dependencies: - - name: lvm - repo: git - source: https://github.com/saltstack-formulas/lvm-formula.git state_top: base: '*': diff --git a/pre-commit_semantic-release.sh b/pre-commit_semantic-release.sh new file mode 100755 index 0000000..9d34d74 --- /dev/null +++ b/pre-commit_semantic-release.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +############################################################################### +# (A) Update `FORMULA` with `${nextRelease.version}` +############################################################################### +sed -i -e "s_^\(version:\).*_\1 ${1}_" FORMULA + + +############################################################################### +# (B) Use `m2r` to convert automatically produced `.md` docs to `.rst` +############################################################################### + +# Install `m2r` +sudo -H pip install m2r + +# Copy and then convert the `.md` docs +cp *.md docs/ +cd docs/ +m2r --overwrite *.md + +# Change excess `H1` headings to `H2` in converted `CHANGELOG.rst` +sed -i -e '/^=.*$/s/=/-/g' CHANGELOG.rst +sed -i -e '1,4s/-/=/g' CHANGELOG.rst + +# Use for debugging output, when required +# cat AUTHORS.rst +# cat CHANGELOG.rst + +# Return back to the main directory +cd .. diff --git a/release-rules.js b/release-rules.js new file mode 100644 index 0000000..c63c850 --- /dev/null +++ b/release-rules.js @@ -0,0 +1,18 @@ +// No release is triggered for the types commented out below. +// Commits using these types will be incorporated into the next release. +// +// NOTE: Any changes here must be reflected in `CONTRIBUTING.md`. +module.exports = [ + {breaking: true, release: 'major'}, + // {type: 'build', release: 'patch'}, + // {type: 'chore', release: 'patch'}, + // {type: 'ci', release: 'patch'}, + {type: 'docs', release: 'patch'}, + {type: 'feat', release: 'minor'}, + {type: 'fix', release: 'patch'}, + {type: 'perf', release: 'patch'}, + {type: 'refactor', release: 'patch'}, + {type: 'revert', release: 'patch'}, + {type: 'style', release: 'patch'}, + {type: 'test', release: 'patch'}, +]; diff --git a/release.config.js b/release.config.js new file mode 100644 index 0000000..afa0cb1 --- /dev/null +++ b/release.config.js @@ -0,0 +1,106 @@ +module.exports = { + branch: 'master', + plugins: [ + ['@semantic-release/commit-analyzer', { + preset: 'angular', + releaseRules: './release-rules.js', + }], + '@semantic-release/release-notes-generator', + ['@semantic-release/changelog', { + changelogFile: 'CHANGELOG.md', + changelogTitle: '# Changelog', + }], + ['@semantic-release/exec', { + prepareCmd: 'sh ./pre-commit_semantic-release.sh ${nextRelease.version}', + }], + ['@semantic-release/git', { + assets: ['*.md', 'docs/*.rst', 'FORMULA'], + }], + '@semantic-release/github', + ], + generateNotes: { + preset: 'angular', + writerOpts: { + // Required due to upstream bug preventing all types being displayed. + // Bug: https://github.com/conventional-changelog/conventional-changelog/issues/317 + // Fix: https://github.com/conventional-changelog/conventional-changelog/pull/410 + transform: (commit, context) => { + const issues = [] + + commit.notes.forEach(note => { + note.title = `BREAKING CHANGES` + }) + + // NOTE: Any changes here must be reflected in `CONTRIBUTING.md`. + if (commit.type === `feat`) { + commit.type = `Features` + } else if (commit.type === `fix`) { + commit.type = `Bug Fixes` + } else if (commit.type === `perf`) { + commit.type = `Performance Improvements` + } else if (commit.type === `revert`) { + commit.type = `Reverts` + } else if (commit.type === `docs`) { + commit.type = `Documentation` + } else if (commit.type === `style`) { + commit.type = `Styles` + } else if (commit.type === `refactor`) { + commit.type = `Code Refactoring` + } else if (commit.type === `test`) { + commit.type = `Tests` + } else if (commit.type === `build`) { + commit.type = `Build System` + // } else if (commit.type === `chore`) { + // commit.type = `Maintenance` + } else if (commit.type === `ci`) { + commit.type = `Continuous Integration` + } else { + return + } + + if (commit.scope === `*`) { + commit.scope = `` + } + + if (typeof commit.hash === `string`) { + commit.hash = commit.hash.substring(0, 7) + } + + if (typeof commit.subject === `string`) { + let url = context.repository + ? `${context.host}/${context.owner}/${context.repository}` + : context.repoUrl + if (url) { + url = `${url}/issues/` + // Issue URLs. + commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => { + issues.push(issue) + return `[#${issue}](${url}${issue})` + }) + } + if (context.host) { + // User URLs. + commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => { + if (username.includes('/')) { + return `@${username}` + } + + return `[@${username}](${context.host}/${username})` + }) + } + } + + // remove references that already appear in the subject + commit.references = commit.references.filter(reference => { + if (issues.indexOf(reference.issue) === -1) { + return true + } + + return false + }) + + return commit + }, + }, + }, +}; diff --git a/test/integration/default/inspec.yml b/test/integration/default/inspec.yml index e15862a..c1c38ec 100644 --- a/test/integration/default/inspec.yml +++ b/test/integration/default/inspec.yml @@ -15,3 +15,4 @@ supports: - platform-name: suse - platform-name: freebsd - platform-name: amazon + - platform-name: arch From 804749e06d6cdac71a4b1b5f256d95cfdf88e8ff Mon Sep 17 00:00:00 2001 From: N Date: Tue, 24 Sep 2019 10:31:52 +0100 Subject: [PATCH 10/10] docs(readme): fix duplicate clean; remove unused config.sls file --- docs/README.rst | 24 ++---------- lvm/config.sls | 100 ------------------------------------------------ 2 files changed, 4 insertions(+), 120 deletions(-) delete mode 100644 lvm/config.sls diff --git a/docs/README.rst b/docs/README.rst index 4af9cad..315b7ad 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -86,6 +86,10 @@ Meta-state to run all volume group states in sequence: 'cfgbackup', 'import', 'r ^^^^^^^^^^ Meta-state to run all logical volume states in sequence: Order 'remove', 'change', 'reduce', 'extend', 'rename', 'create', 'convert', and 'create' again. +``lvm.clean`` +^^^^^^^^^^^^^ +Meta-state to run all clean states provided by this formula. + Available substates ------------------- @@ -93,30 +97,10 @@ Available substates .. contents:: :local: -``lvm.clean`` -^^^^^^^^^^^^^ -Remove lvm2 software. - -``lvm.profiles.clean`` -^^^^^^^^^^^^^^^^^^^^^^ -Remove custom lvm profile(s):: - - profiles: - remove: - - sillyprofile - ``lvm.install`` ^^^^^^^^^^^^^^^ Install lvm2 package. -``lvm.config (deprecated)`` -^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Configure PVs, VGs and LVs using legacy pillar data (backwards compatibility only). - -``lvm.clean`` -^^^^^^^^^^^^^ -Remove lvm2 software. - ``lvm.profiles.clean`` ^^^^^^^^^^^^^^^^^^^^^^ Remove custom lvm profile(s):: diff --git a/lvm/config.sls b/lvm/config.sls deleted file mode 100644 index 4169be0..0000000 --- a/lvm/config.sls +++ /dev/null @@ -1,100 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: ft=sls -## LEGACY STATE (BACKWARDS COMPATIBLE) FUTURE TODO: REMOVE ## - -{% from "lvm/map.jinja" import lvm_settings with context %} - -{# Creation order: pv -> vg -> lv #} - -{% if 'pv' in lvm_settings and lvm_settings.pv %} -{% for pv,pv_options in lvm_settings.pv.items() %} -{% if ( 'enabled' in pv_options and pv_options.enabled ) or 'enabled' not in pv_options %} - -lvm.pv.create_{{ pv_options.device|default(pv) }}: - lvm.pv_present: - - name: {{ pv_options.device|default(pv) }} - {% if 'options' in pv_options and pv_options.options %} - {% for opt,value in pv_options.options.items() %} - - {{ opt }}: {{ value }} - {% endfor %} - {% endif %} - -{% endif %} -{% endfor %} -{% endif %} - -{% if 'vg' in lvm_settings and lvm_settings.vg %} -{% for vg,vg_options in lvm_settings.vg.items() %} -{% if ( 'enabled' in vg_options and vg_options.enabled ) or 'enabled' not in vg_options %} - -lvm.vg.create_{{ vg_options.name|default(vg) }}: - lvm.vg_present: - - name: {{ vg_options.name|default(vg) }} - - devices: {{ vg_options.devices|json }} - {% if 'options' in vg_options and vg_options.options %} - {% for opt,value in vg_options.options.items() %} - - {{ opt }}: {{ value }} - {% endfor %} - {% endif %} - -{% endif %} -{% endfor %} -{% endif %} - -{% if 'lv' in lvm_settings and lvm_settings.lv %} -{% for lv,lv_options in lvm_settings.lv.items() %} -{% if ( 'enabled' in lv_options and lv_options.enabled ) or 'enabled' not in lv_options %} - -lvm.lv.create_{{ lv_options.name|default(lv) }}: - lvm.lv_present: - - name: {{ lv_options.name|default(lv) }} - - vgname: {{ lv_options.vgname }} - {% if 'options' in lv_options and lv_options.options %} - {% for opt,value in lv_options.options.items() %} - - {{ opt }}: {{ value }} - {% endfor %} - {% endif %} - -{% endif %} -{% endfor %} -{% endif %} - - -{# Deletion order: lv -> vg -> pv #} - -{% if 'lv' in lvm_settings and lvm_settings.lv %} -{% for lv,lv_options in lvm_settings.lv.items() %} -{% if 'enabled' in lv_options and not lv_options.enabled %} - -lvm.lv.remove_{{ lv_options.name|default(lv) }}: - lvm.lv_absent: - - name: {{ lv_options.name|default(lv) }} - - vgname: {{ lv_options.vgname }} - -{% endif %} -{% endfor %} -{% endif %} - -{% if 'vg' in lvm_settings and lvm_settings.vg %} -{% for vg,vg_options in lvm_settings.vg.items() %} -{% if 'enabled' in vg_options and not vg_options.enabled %} - -lvm.vg.remove_{{ vg_options.name|default(vg) }}: - lvm.vg_absent: - - name: {{ vg_options.name|default(vg) }} - -{% endif %} -{% endfor %} -{% endif %} - -{% if 'pv' in lvm_settings and lvm_settings.pv %} -{% for pv,pv_options in lvm_settings.pv.items() %} -{% if 'enabled' in pv_options and not pv_options.enabled %} - -lvm.pv.remove_{{ pv_options.device|default(pv) }}: - lvm.pv_absent: - - name: {{ pv_options.device|default(pv) }} - -{% endif %} -{% endfor %} -{% endif %}