1

I am creating one RHEL7.8 machine with s390x arch in Openstack using terraform and running init.sh file in user_data I got the below error log while executing any command in init.sh file.

my init.sh file

echo "Start executing bootstrap...\n"
echo -e "${root_pwd}\n${root_pwd}" | sudo passwd root
echo "Changed Root account password"
sudo yum update -y

i got below error msg

Start executing bootstrap...\n
sudo: Account or password is expired, reset your password and try again
Changing password for root.
sudo: no tty present and no askpass program specified
sudo: unable to change expired password: Authentication token manipulation error
Changed Root account password
sudo: Account or password is expired, reset your password and try again
sudo: no tty present and no askpass program specified
sudo: unable to change expired password: Authentication token manipulation error

When I login to machine manually and try sudo passwd root it is working fine. Why it is not working through terraform

  • Are you manually logging on to the machine using the same credentials as Terraform uses to connect? – T.H. Sep 18 '20 at 16:44
  • Yes I am using key to login machine.and in Terraform also I am using key to connect machine.but here I am executing `init.sh` file in user_data – Bhagyashri Machale Sep 18 '20 at 16:55
  • I'm just guessing here, but is there perhaps some VM initialisation task that hasn't completed before the scripted sudo is attempted, but completes before your manual try? Perhaps adding a delay to the script will resolve this. – T.H. Sep 18 '20 at 17:16
  • You mean delaying `user_data` execution? – Bhagyashri Machale Sep 18 '20 at 17:47
  • I delayed execution of script but still having issue – Bhagyashri Machale Sep 18 '20 at 19:41
  • I mean put a longish delay as the first line of the init.sh script. Is that what you did? If that didn't work, have you confirmed that sudo passwd root works fine the first time you log in even if you leave user_data completely blank--which if it doesn't suggests that there's something later in user_data that makes it subsequently work. – T.H. Sep 19 '20 at 12:30

1 Answers1

0

you can try by removing sudo from "sudo yum update -y" command if you are already in root.

RanjitRay
  • 41
  • 4