install xfs

This commit is contained in:
Charlie Mordant
2020-04-23 19:25:09 +02:00
parent 7d3e90f9e8
commit 325c2d6240
11 changed files with 124 additions and 88 deletions

View File

@@ -34,67 +34,8 @@ jobs:
sudo apt update
sudo apt -y install python3-setuptools python3 python3-pip docker vagrant
sudo pip3 install wheel
sudo pip3 install docker molecule testinfra yamllint ansible-lint flake8 molecule-vagrant
sudo pip3 install molecule testinfra yamllint ansible-lint flake8 molecule-vagrant
- name: molecule lint
run: |
molecule lint
molecule:
runs-on: ubuntu-latest
if: "false"
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2
- name: configure keyboard layout
run: |
echo XKBLAYOUT='us' > /etc/default/keyboard
- name: install virtualization stack
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt -y install cpu-checker
kvm-ok
# shit happens here, containerization sucks... that was worth the try
- name: install virtualization stack
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt -y install policycoreutils-python-utils qemu-kvm qemu-utils libvirt-clients libvirt-daemon-system bridge-utils python3-libvirt libnss-libvirt libguestfs-tools virtinst virt-top genisoimage libvirt-dev libvirt-bin
- name: install vagrant
env:
VAGRANT_DISABLE_STRICT_DEPENDENCY_ENFORCEMENT: 1
run: |
wget https://releases.hashicorp.com/vagrant/2.2.7/vagrant_2.2.7_x86_64.deb
sudo apt -y install ./vagrant_2.2.7_x86_64.deb
vagrant plugin install vagrant-persistent-storage
vagrant plugin install vagrant-libvirt
sudo groupadd --system libvirt
sudo usermod -a -G libvirt $(whoami)
sudo /etc/init.d/libvirtd restart
- name: Install molecule
run: |
sudo apt -y install python3-setuptools
pip3 install molecule-vagrant wheel
- name: create molecule vm
env:
LC_ALL: C.UTF-8
LANG: C.UTF-8
run: |
molecule create --scenario-name kvm
- name: verify
run: |
molecule verify
- name: teardown
run: |
molecule destroy

View File

@@ -1,15 +1,30 @@
---
sudo: required
dist: bionic
language: python
services:
- docker
python:
- "3.8"
before_install:
- sudo apt-get -qq update
install:
- pip3 install -r requirements.txt
- ansible --version
- molecule --version
- |
sudo apt -y install bridge-utils dnsmasq-base ebtables libvirt-bin libvirt-dev qemu-kvm qemu-utils ruby-dev
- |
wget https://releases.hashicorp.com/vagrant/2.2.7/vagrant_2.2.7_x86_64.deb
sudo apt -y install ./vagrant_2.2.7_x86_64.deb
sudo vagrant plugin install vagrant-libvirt
- |
sudo apt-get -y purge python3-openssl && sudo apt-get -y autoremove
sudo apt-get update && sudo apt-get install -y ca-certificates curl gcc iproute2 python3 python3-dev sudo
curl -skL https://bootstrap.pypa.io/get-pip.py | sudo -H python3
sudo pip3 install wheel
sudo pip3 install netaddr python-vagrant yamllint testinfra flake8
sudo pip3 install ansible ansible-lint
sudo pip3 install -I molecule molecule-vagrant
script:
- molecule lint
- |
sudo molecule test --scenario-name kvm
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View File

@@ -6,6 +6,10 @@ galaxy_info:
license: MIT
min_ansible_version: 1.2
platforms:
- name: fedora
versions:
- 31
- name: EL
versions:
- 6
@@ -21,4 +25,5 @@ galaxy_info:
galaxy_tags:
- system
- lvm
dependencies: []

View File

@@ -23,7 +23,6 @@
filesystem: xfs
mntp: "/var/lib/mountpoint2"
manage_lvm: true
tasks:
- name: "Include lvm"
include_role:

View File

@@ -3,11 +3,12 @@ driver:
name: vagrant
provider:
name: virtualbox
lint: yamllint . && flake8 && ansible-lint --exclude=meta
lint: yamllint . && flake8 && ansible-lint
platforms:
- name: Fedora-Molecule-LVM
box: bento/fedora-31
# box-url: ${platform_root}/packer/bento/builds/fedora-31-x86_64.virtualbox.box
box: fedora/31-cloud-base
cpu: 2
memory: 2048
provider_override_args:
- "persistent_storage.enabled = true"
- "persistent_storage.location = 'molecule-lvm.vdi'"
@@ -16,9 +17,6 @@ platforms:
- "persistent_storage.diskdevice = '/dev/sdb'"
provisioner:
name: ansible
inventory:
group_vars:
lvm:
verifier:
name: testinfra
env:

29
molecule/kvm/converge.yml Normal file
View File

@@ -0,0 +1,29 @@
---
- name: Converge
hosts: all
vars:
lvm_groups:
- vgname: my_vg
disks:
- /dev/vdb
create: true
lvnames:
- lvname: my_lv
size: 40%VG
opts: "--wipesignatures y"
create: true
filesystem: ext4
mount: true
mntp: "/var/lib/mountpoint"
- lvname: my_lv2
size: 20%VG
opts: "--wipesignatures y"
mount: true
create: true
filesystem: xfs
mntp: "/var/lib/mountpoint2"
manage_lvm: true
tasks:
- name: "Include lvm"
include_role:
name: "ansible-manage-lvm"

32
molecule/kvm/molecule.yml Normal file
View File

@@ -0,0 +1,32 @@
---
driver:
name: vagrant
provider:
name: libvirt
lint: yamllint . && flake8 && ansible-lint
platforms:
- name: Fedora-Molecule-Volumes-KVM
box: fedora/31-cloud-base
cpu: 2
memory: 2048
provider_raw_config_args:
- "storage :file, :size => '1G', :device => 'vdb'"
provisioner:
name: ansible
config_options:
defaults:
forks: 20
ssh_connection:
pipelining: true
ssh_args: -o ControlMaster=auto -o ControlPersist=600s
env:
ANSIBLE_ROLES_PATH: ../../..:../../../community
verifier:
name: testinfra
env:
PYTHONWARNINGS: "ignore:.*U.*mode is deprecated:DeprecationWarning"
options:
v: 1
scenario:
name: kvm

1
molecule/kvm/tests Symbolic link
View File

@@ -0,0 +1 @@
../default/tests

View File

@@ -11,23 +11,34 @@
state: "present"
become: true
- name: "debug lvg"
debug:
var: lv
verbosity: 3
loop: "{{ lookup('subelements', lvm_groups, 'lvnames', {'skip_missing': True}) }}"
loop_control:
loop_var: lv
- name: centos | install xfs tools
package:
name: "xfsprogs"
state: "present"
become: yes
loop: "{{ lvm_groups|subelements('lvnames') }}"
become: true
loop: "{{ lookup('subelements', lvm_groups, 'lvnames', {'skip_missing': True}) }}"
loop_control:
loop_var: lv
when: >
(
(item.1 is defined and item.1 != 'None') and
(lv.1 is defined and lv.1 != 'None') and
(
item.1.filesystem is defined and
item.1.filesystem == "xfs"
lv.1.filesystem is defined and
lv.1.filesystem == "xfs"
)
and
(
item.1.create is defined and
item.1.create
lv.1.create is defined and
lv.1.create
)
)
@@ -35,9 +46,9 @@
command: "sg_scan"
become: true
register: "scsi_devices"
changed_when: False
changed_when: false
- name: centos | rescanning for new disks
command: "/usr/bin/rescan-scsi-bus.sh"
become: true
changed_when: False
changed_when: false

View File

@@ -50,7 +50,7 @@
loop_control:
loop_var: lv
register: mountedxfs
ignore_errors: True
ignore_errors: true
changed_when: no
when: >
(

View File

@@ -1,9 +1,14 @@
---
- debug: var=vg
- name: "debug vg"
debug:
var: vg
verbosity: 2
- name: "debug lvm"
loop: "{{ vg.lvnames }}"
debug: var=lv
debug:
var: lv
verbosity: 1
loop_control:
loop_var: lv