ansible / ansible-modules-extras

Ansible extra modules - these modules ship with ansible
948 stars 1.46k forks source link

lvol is trying to shrink logical volume with fixed size when executed twice #3506

Closed thiagoalves closed 7 years ago

thiagoalves commented 7 years ago

ISSUE TYPE: Bug Report COMPONENT NAME: lvol ANSIBLE VERSION: ansible 2.2.0.0 CONFIGURATION: no changes OS / ENVIRONMENT: Ubuntu xenial 16.04 (Linux 4.4.0-47-generic #68-Ubuntu SMP x86_64) -

SUMMARY

lvol is creating the logical volume correctly at the first run, but after running the same playbook again without modifications, an error message is displayed: "Sorry, no shrinking of lv_default without force=yes."

STEPS TO REPRODUCE

1) Log on an ec2 instance with ansible 2.2 installed and ec2 dynamic inventory enabled

2) Create lvm.yml file with the following content:

- hosts: localhost
  tasks:
  - name: Get ec2 facts
    local_action: ec2_facts

  - name: Create and attach EBS volume
    ec2_vol:
      volume_size: 1
      region: us-east-1
      instance: "{{ ansible_ec2_instance_id }}"
      device_name: /dev/xvdz

  - name: Create LVM volume group
    become: yes
    lvg:
      vg: vg_default
      pvs: /dev/xvdz

  - name: Create LVM logical volumes inside the volume group
    become: yes
    lvol: vg=vg_default lv=lv_default size="1013m"

3) Execute ansible-playbook lvm-bug.yml - the volume will be created 3) Execute the same playbook again - an error message will be displayed: "Sorry, no shrinking of lv_default without force=yes."

EXPECTED RESULTS

Volume should be created at the first run, and subsequent runs should have no effect and no error messages should be displayed

ACTUAL RESULTS

An error message is displayed:

talves@ip-10-69-11-150:~$ ansible-playbook lvm-bug.yml -vvvvv
Using /etc/ansible/ansible.cfg as config file
 [WARNING]: provided hosts list is empty, only localhost is available

Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/dist-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK: lvm-bug.yml **********************************************************
1 plays in lvm-bug.yml

PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/system/setup.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: talves
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1479749874.91-104034913293139 `" && echo ansible-tmp-1479749874.91-104034913293139="` echo $HOME/.ansible/tmp/ansible-tmp-1479749874.91-104034913293139 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpv78jbF TO /home/talves/.ansible/tmp/ansible-tmp-1479749874.91-104034913293139/setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/talves/.ansible/tmp/ansible-tmp-1479749874.91-104034913293139/ /home/talves/.ansible/tmp/ansible-tmp-1479749874.91-104034913293139/setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/talves/.ansible/tmp/ansible-tmp-1479749874.91-104034913293139/setup.py; rm -rf "/home/talves/.ansible/tmp/ansible-tmp-1479749874.91-104034913293139/" > /dev/null 2>&1 && sleep 0'
ok: [localhost]

TASK [Get ec2 facts] ***********************************************************
task path: /home/talves/lvm-bug.yml:3
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/cloud/amazon/ec2_facts.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: talves
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1479749875.36-75305735143672 `" && echo ansible-tmp-1479749875.36-75305735143672="` echo $HOME/.ansible/tmp/ansible-tmp-1479749875.36-75305735143672 `" ) && sleep 0'
<localhost> PUT /tmp/tmp4zkGha TO /home/talves/.ansible/tmp/ansible-tmp-1479749875.36-75305735143672/ec2_facts.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/talves/.ansible/tmp/ansible-tmp-1479749875.36-75305735143672/ /home/talves/.ansible/tmp/ansible-tmp-1479749875.36-75305735143672/ec2_facts.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /home/talves/.ansible/tmp/ansible-tmp-1479749875.36-75305735143672/ec2_facts.py; rm -rf "/home/talves/.ansible/tmp/ansible-tmp-1479749875.36-75305735143672/" > /dev/null 2>&1 && sleep 0'
ok: [localhost -> localhost] => {
    "ansible_facts": {
        "ansible_ec2_ami_id": "ami-78b4976f",
        "ansible_ec2_ami_launch_index": "0",
        "ansible_ec2_ami_manifest_path": "(unknown)",
        "ansible_ec2_block_device_mapping_ami": "/dev/sda1",
        "ansible_ec2_block_device_mapping_root": "/dev/sda1",
        "ansible_ec2_hostname": "ip-10-69-11-150.devfactory.local",
        "ansible_ec2_instance_action": "none",
        "ansible_ec2_instance_id": "i-0c7d71e6ac0595b17",
        "ansible_ec2_instance_type": "t2.micro",
        "ansible_ec2_local_hostname": "ip-10-69-11-150.devfactory.local",
        "ansible_ec2_local_ipv4": "10.69.11.150",
        "ansible_ec2_mac": "12:27:d0:65:16:aa",
        "ansible_ec2_metrics_vhostmd": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
        "ansible_ec2_network_interfaces_macs_12_27_d0_65_16_aa_device_number": "0",
        "ansible_ec2_network_interfaces_macs_12_27_d0_65_16_aa_interface_id": "eni-8f846c70",
        "ansible_ec2_network_interfaces_macs_12_27_d0_65_16_aa_ipv4_associations_34.192.201.42": "10.69.11.150",
        "ansible_ec2_network_interfaces_macs_12_27_d0_65_16_aa_local_hostname": "ip-10-69-11-150.devfactory.local",
        "ansible_ec2_network_interfaces_macs_12_27_d0_65_16_aa_local_ipv4s": "10.69.11.150",
        "ansible_ec2_network_interfaces_macs_12_27_d0_65_16_aa_mac": "12:27:d0:65:16:aa",
        "ansible_ec2_network_interfaces_macs_12_27_d0_65_16_aa_owner_id": "646253092271",
        "ansible_ec2_network_interfaces_macs_12_27_d0_65_16_aa_public_hostname": "ec2-34-192-201-42.compute-1.amazonaws.com",
        "ansible_ec2_network_interfaces_macs_12_27_d0_65_16_aa_public_ipv4s": "34.192.201.42",
        "ansible_ec2_network_interfaces_macs_12_27_d0_65_16_aa_security_group_ids": "sg-ed3d1296",
        "ansible_ec2_network_interfaces_macs_12_27_d0_65_16_aa_security_groups": "ecs-private",
        "ansible_ec2_network_interfaces_macs_12_27_d0_65_16_aa_subnet_id": "subnet-d64c60fc",
        "ansible_ec2_network_interfaces_macs_12_27_d0_65_16_aa_subnet_ipv4_cidr_block": "10.69.11.0/24",
        "ansible_ec2_network_interfaces_macs_12_27_d0_65_16_aa_vpc_id": "vpc-a79317c0",
        "ansible_ec2_network_interfaces_macs_12_27_d0_65_16_aa_vpc_ipv4_cidr_block": "10.69.0.0/20",
        "ansible_ec2_network_interfaces_macs_12_27_d0_65_16_aa_vpc_ipv4_cidr_blocks": "10.69.0.0/20",
        "ansible_ec2_placement_availability_zone": "us-east-1c",
        "ansible_ec2_placement_region": "us-east-1",
        "ansible_ec2_profile": "default-hvm",
        "ansible_ec2_public_hostname": "ec2-34-192-201-42.compute-1.amazonaws.com",
        "ansible_ec2_public_ipv4": "34.192.201.42",
        "ansible_ec2_public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCihoNkm/3LelqzXoqJtZ1ORi5EGc97+03Q5+pBeWxJ7Lf14UemxYJEWWXlQo+RbebvsSBAha0o8sfPWg7qJEOyMRWITQG0w9K+eX362Bl2IY0EY2cFzj+gXdZdMlUTZTGR/C3g2YmzmZxE35YwEfJ/BcAEhyKf6L4x9bxvOTVPPa6a1+wsqLlIIy+1Nh4aTLGlEwnCfpA5d+TbTB+H505Pu1m82x9CO5u5aOPG5ZMPX8xwA3zzPepLbQsH/HSK5w2WPGB/Fe2yA2j0vDwiOhtcx9SG+SZMZtzs5rvn7QbHSnTjPp5oNUjj1JTXbKX6JatdZT2uUCmCilO7K2yZO7Tt central-docker-team\n",
        "ansible_ec2_reservation_id": "r-0b3aab7de7254c9bd",
        "ansible_ec2_security_groups": "ecs-private",
        "ansible_ec2_services_domain": "amazonaws.com",
        "ansible_ec2_services_partition": "aws",
        "ansible_ec2_user_data": null
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "force": false,
            "force_basic_auth": false,
            "http_agent": "ansible-httpget",
            "url": null,
            "url_password": null,
            "url_username": null,
            "use_proxy": true,
            "validate_certs": true
        },
        "module_name": "ec2_facts"
    }
}

TASK [Create and attach EBS volume] ********************************************
task path: /home/talves/lvm-bug.yml:6
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/cloud/amazon/ec2_vol.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: talves
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1479749875.76-182263987502352 `" && echo ansible-tmp-1479749875.76-182263987502352="` echo $HOME/.ansible/tmp/ansible-tmp-1479749875.76-182263987502352 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmp3YBDj6 TO /home/talves/.ansible/tmp/ansible-tmp-1479749875.76-182263987502352/ec2_vol.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/talves/.ansible/tmp/ansible-tmp-1479749875.76-182263987502352/ /home/talves/.ansible/tmp/ansible-tmp-1479749875.76-182263987502352/ec2_vol.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/talves/.ansible/tmp/ansible-tmp-1479749875.76-182263987502352/ec2_vol.py; rm -rf "/home/talves/.ansible/tmp/ansible-tmp-1479749875.76-182263987502352/" > /dev/null 2>&1 && sleep 0'
ok: [localhost] => {
    "changed": false,
    "device": "/dev/xvdz",
    "invocation": {
        "module_args": {
            "aws_access_key": null,
            "aws_secret_key": null,
            "delete_on_termination": false,
            "device_name": "/dev/xvdz",
            "ec2_url": null,
            "encrypted": false,
            "id": null,
            "instance": "i-0c7d71e6ac0595b17",
            "iops": null,
            "name": null,
            "profile": null,
            "region": "us-east-1",
            "security_token": null,
            "snapshot": null,
            "state": "present",
            "validate_certs": true,
            "volume_size": "1",
            "volume_type": "standard",
            "zone": null
        },
        "module_name": "ec2_vol"
    },
    "msg": "Volume mapping for /dev/xvdz already exists on instance i-0c7d71e6ac0595b17",
    "volume_id": "vol-606c80f3"
}

TASK [Create LVM volume group] *************************************************
task path: /home/talves/lvm-bug.yml:13
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/extras/system/lvg.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: talves
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1479749876.26-228386796421141 `" && echo ansible-tmp-1479749876.26-228386796421141="` echo $HOME/.ansible/tmp/ansible-tmp-1479749876.26-228386796421141 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpHpRJZq TO /home/talves/.ansible/tmp/ansible-tmp-1479749876.26-228386796421141/lvg.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/talves/.ansible/tmp/ansible-tmp-1479749876.26-228386796421141/ /home/talves/.ansible/tmp/ansible-tmp-1479749876.26-228386796421141/lvg.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-ptheuhxyltmmgljgmwhjwolcddmexicc; /usr/bin/python /home/talves/.ansible/tmp/ansible-tmp-1479749876.26-228386796421141/lvg.py; rm -rf "/home/talves/.ansible/tmp/ansible-tmp-1479749876.26-228386796421141/" > /dev/null 2>&1'"'"' && sleep 0'
ok: [localhost] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "force": false,
            "pesize": 4,
            "pvs": [
                "/dev/xvdz"
            ],
            "state": "present",
            "vg": "vg_default",
            "vg_options": ""
        },
        "module_name": "lvg"
    }
}

TASK [Create LVM logical volumes inside the volume group] **********************
task path: /home/talves/lvm-bug.yml:19
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/extras/system/lvol.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: talves
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1479749876.63-200489056793585 `" && echo ansible-tmp-1479749876.63-200489056793585="` echo $HOME/.ansible/tmp/ansible-tmp-1479749876.63-200489056793585 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpfKsPsA TO /home/talves/.ansible/tmp/ansible-tmp-1479749876.63-200489056793585/lvol.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/talves/.ansible/tmp/ansible-tmp-1479749876.63-200489056793585/ /home/talves/.ansible/tmp/ansible-tmp-1479749876.63-200489056793585/lvol.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-dvukcdtkvvbvnxuopibtdcxeczhjasyt; /usr/bin/python /home/talves/.ansible/tmp/ansible-tmp-1479749876.63-200489056793585/lvol.py; rm -rf "/home/talves/.ansible/tmp/ansible-tmp-1479749876.63-200489056793585/" > /dev/null 2>&1'"'"' && sleep 0'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "failed": true,
    "invocation": {
        "module_args": {
            "active": true,
            "force": false,
            "lv": "lv_default",
            "opts": null,
            "pvs": null,
            "shrink": true,
            "size": "1013m",
            "snapshot": null,
            "state": "present",
            "vg": "vg_default"
        },
        "module_name": "lvol"
    },
    "msg": "Sorry, no shrinking of lv_default without force=yes."
}
        to retry, use: --limit @/home/talves/lvm-bug.retry

PLAY RECAP *********************************************************************
localhost                  : ok=4    changed=0    unreachable=0    failed=1
ansibot commented 7 years ago

@jhoekx, @abulimov, ping. This issue is waiting on your response. click here for bot help

angystardust commented 7 years ago

@thiagoalves this issue has already been reported in #428

ansibot commented 7 years ago

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.