I'm trying to run a rescan and pvresize after growing a disk but the shell module is returning an rc 127 and these error lines.
"stderr_lines": [
"/bin/bash: echo '1' > /sys/class/block/sdd/device/rescan: No such file or directory",
"/bin/bash: line 1: pvresize /dev/sdd: No such file or directory"
],
This is the code snippet, I've tried with and without setting the /bin/bash shell and its the same error.
- name: set disk var
set_fact:
disk: /dev/sdd
- name: rescan and resize
shell: |
"echo '1' > /sys/class/block/{{ disk[5:8] }}/device/rescan"
"pvresize {{ disk }}"
become: true
args:
executable: /bin/bash
environment:
PATH: "/usr/local/sbin:/sbin:/usr/sbin:{{ ansible_env.PATH }}"
I've seen this error before in the command module but adding the sbin to the PATH fixed that there. I am trying to do this with the shell module because even though it says when using the command module that it passes, when actually on the machine it did not and gave a false positive. It did not actually resize the PV and therefore the volume group its part of also did not. So I am trying to test with shell and see if it works.
This is the command module version
- name: resize physical volume
command: "{{ item }}"
with_items:
- "echo '1' > /sys/class/block/{{ disk[5:8] }}/device/rescan" #rescan scsi bus
- "pvresize {{ disk }}"
become: true
environment:
PATH: "/usr/local/sbin:/sbin:/usr/sbin:{{ ansible_env.PATH }}"