Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider failing earlier when no device is provided #63

Open
tabowling opened this issue Nov 1, 2019 · 1 comment
Open

consider failing earlier when no device is provided #63

tabowling opened this issue Nov 1, 2019 · 1 comment

Comments

@tabowling
Copy link
Contributor

tabowling commented Nov 1, 2019

I accidentally executed a playbook using the storage role where I did not have a device defined. Would it be good to detect very early that a device name is NULL or invalid before executing so much of the logic? Below is the snippet from my playbook:

    - name: Configure Image Builder Storage
      include_role:
        name: linux-system-roles.storage
      vars:
        use_partitions: false
        storage_pools:
          - name: image_builder
            disks: ['']  # something like vdb
            # type: lvm
            state: present
            volumes:
              - name: composer
                size: "19.5G"
                # type: lvm
                # fs_type: xfs
                fs_label: "imgbldr"
                mount_point: '/var/lib/lorax/composer'
      when: CONFIG_STORAGE
@tabowling
Copy link
Contributor Author

here is the output it generated:

`
TASK [linux-system-roles.storage : define an empty list of pools to be used in testing] ***************************************
ok: [rhel8beta]

TASK [linux-system-roles.storage : define an empty list of volumes to be used in testing] *************************************
ok: [rhel8beta]

TASK [linux-system-roles.storage : include the appropriate backend tasks] *****************************************************
included: /usr/share/ansible/roles/linux-system-roles.storage/tasks/main-blivet.yml for rhel8beta

TASK [linux-system-roles.storage : get a list of rpm packages installed on host machine] **************************************
skipping: [rhel8beta]

TASK [linux-system-roles.storage : make sure blivet is available] *************************************************************
changed: [rhel8beta]

TASK [linux-system-roles.storage : initialize internal facts] *****************************************************************
ok: [rhel8beta]

TASK [linux-system-roles.storage : Apply defaults to pools and volumes [1/6]] *************************************************
ok: [rhel8beta] => (item={'name': 'image_builder', 'disks': [''], 'state': 'present', 'volumes': [{'name': 'composer', 'size': '19.5G', 'fs_label': 'imgbldr', 'mount_point': '/var/lib/lorax/composer'}]})

TASK [linux-system-roles.storage : Apply defaults to pools and volumes [2/6]] *************************************************
ok: [rhel8beta] => (item=[{'state': 'present', 'type': 'lvm', 'name': 'image_builder', 'disks': [''], 'volumes': [{'name': 'composer', 'size': '19.5G', 'fs_label': 'imgbldr', 'mount_point': '/var/lib/lorax/composer'}]}, {'name': 'composer', 'size': '19.5G', 'fs_label': 'imgbldr', 'mount_point': '/var/lib/lorax/composer'}])

TASK [linux-system-roles.storage : Apply defaults to pools and volumes [3/6]] *************************************************
ok: [rhel8beta] => (item=[{'name': 'composer', 'size': '19.5G', 'fs_label': 'imgbldr', 'mount_point': '/var/lib/lorax/composer'}, {'state': 'present', 'type': 'lvm', 'size': 0, 'fs_type': 'xfs', 'fs_label': '', 'fs_create_options': '', 'fs_overwrite_existing': True, 'mount_point': '', 'mount_options': 'defaults', 'mount_check': 0, 'mount_passno': 0, 'mount_device_identifier': 'uuid'}])

TASK [linux-system-roles.storage : Apply defaults to pools and volumes [4/6]] *************************************************
ok: [rhel8beta] => (item={'state': 'present', 'type': 'lvm', 'name': 'image_builder', 'disks': [''], 'volumes': [{'name': 'composer', 'size': '19.5G', 'fs_label': 'imgbldr', 'mount_point': '/var/lib/lorax/composer'}]})

TASK [linux-system-roles.storage : Apply defaults to pools and volumes [5/6]] *************************************************
ok: [rhel8beta] => (item={'state': 'present', 'type': 'lvm', 'name': 'image_builder', 'disks': [''], 'volumes': [{'name': 'composer', 'size': '19.5G', 'fs_label': 'imgbldr', 'mount_point': '/var/lib/lorax/composer'}]})

TASK [linux-system-roles.storage : Apply defaults to pools and volumes [6/6]] *************************************************

TASK [linux-system-roles.storage : debug] *************************************************************************************
ok: [rhel8beta] => {
"_storage_pools": [
{
"disks": [
""
],
"name": "image_builder",
"state": "present",
"type": "lvm",
"volumes": [
{
"fs_create_options": "",
"fs_label": "imgbldr",
"fs_overwrite_existing": true,
"fs_type": "xfs",
"mount_check": 0,
"mount_device_identifier": "uuid",
"mount_options": "defaults",
"mount_passno": 0,
"mount_point": "/var/lib/lorax/composer",
"name": "composer",
"pool": "image_builder",
"size": "19.5G",
"state": "present",
"type": "lvm"
}
]
}
]
}

TASK [linux-system-roles.storage : debug] *************************************************************************************
ok: [rhel8beta] => {
"_storage_volumes": []
}

TASK [linux-system-roles.storage : manage the pools and volumes to match the specified state] *********************************
fatal: [rhel8beta]: FAILED! => {"actions": [], "changed": false, "leaves": [], "mounts": [], "msg": "unable to resolve any disks specified for pool 'image_builder' ([''])", "pools": [], "volumes": []}

PLAY RECAP ********************************************************************************************************************
rhel8beta : ok=24 changed=1 unreachable=0 failed=1 skipped=6 rescued=0 ignored=0

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant