Why expect script not executing with puppet?

asked 2017-04-06 11:00:59 -0500

kingsmasher1 gravatar image

My intent is to add a YUM repository with puppet and search an RPM. When the YUM is added first time, it prompts to enter credentials and prompts the user to trust the keys, for which i created an expect script.

If executed manually, the expect script works as expected, but with puppet it fails. Here is the standalone manual execution without puppet :

{{

Retrieving repository 'QA' metadata [] Authentication required for 'http://10.156.14.121/repo/RPMS/QA/' User Name: insite1 Password:

New repository or package signing key received: Key ID: 04AC56A7D4022AF3 Key Name: DCCA DEVOPS (QA YUM Repo) DL-DCCA-DEVOPS@Dell.com Key Fingerprint: F248468CDB8248387CCF568004AC56A7D4022AF3 Key Created: Tue Aug 16 08:27:37 2016 Key Expires: (does not expire) Repository: QA

Do you want to reject the key, trust temporarily, or trust always? [r/t/a/? shows all options] (r): a Retrieving repository 'QA' metadata [done] Building repository 'QA' cache [done] Loading repository data... Reading installed packages...

S | Name | Type | Version | Arch | Repository --+----------+---------+---------+--------+----------- | dcca-img | package | 9.5.1-2 | x8664 | QA | dcca-img | package | 9.5.1-1 | x8664 | QA

}}

The puppet manifests file is: node default { include base }

class base { exec { "add yum":
command => 'zypper addrepo -f http://10.156.14.121/repo/RPMS/QA/ QA', path => '/usr/bin/' }

exec { "execute expect script":
command => 'myexpect.sh', path
=> '/tmp' } }

The expect script is:

!/usr/bin/expect spawn /usr/bin/zypper se -s dcca-img expect

{ "User Name:" { send "insite1\r"; expcontinue } "Password:" { send "insite2\r"; expcontinue } "Do you want to reject the key, trust temporarily, or trust always?" { send -- "a\r" } } interact

Here is the puppet error :

SLES11SP4-118:/tmp # puppet apply /etc/puppet/manifests/site.pp notice: /Stage[main]/Base/Exec[add yum]/returns: executed successfully err: /Stage[main]/Base/Exec[execute expect script]/returns: change from notrun to 0 failed: myexpect.sh returned 1 instead of one of [0] at /etc/puppet/manifests/site.pp:14 notice: Finished catalog run in 0.27 seconds

Please help.

edit retag flag offensive close merge delete