Closed mmailand closed 8 years ago
There are a couple of options. The most direct answer is that tool is expecting a TTY. One solution is to use tty -s
. Example:
$script = @(END)
#!/bin/bash -x
/usr/bin/FastCli -p 15 -c 'show extension'
END
file { '/usr/local/sbin/update_extension.sh':
content => $script,
owner => root,
group => root,
mode => '0755',
}
exec { 'update_extension':
subscribe => File['/usr/local/sbin/update_extension.sh'],
refreshonly => true,
user => 'root',
group => 'root',
logoutput => true,
command => '/usr/bin/tty -s && /usr/local/sbin/update_extension.sh',
}
Another solution is to utilize raw jsonrpc eAPI calls through Python or some other tool which could give you structured data:
#!/usr/bin/env python
from jsonrpclib import Server
from pprint import pprint
eos = Server("unix:/var/run/command-api.sock")
extensions = eos.runCmds(1, ['show extensions'])
pprint(extensions)
[{'extensions': {'puppet-agent-1.4.2-1.eos4.i386.swix': {'error': False,
'numRpms': 1,
'presence': 'present',
'release': '1.eos4',
'status': 'notInstalled',
'version': '1.4.2'},
'puppet-agent-1.5.2-1.eos4.i386.swix': {'error': False,
'numRpms': 1,
'presence': 'present',
'release': '1.eos4',
'status': 'installed',
'version': '1.5.2'},
'rbeapi-puppet-aio-0.5.1-1.swix': {'error': False,
'numRpms': 4,
'presence': 'present',
'release': '1.eos4',
'status': 'installed',
'version': '0.5.1'}}}]
_NOTE:_ Currently, you must use the EOS copy command to get extensions into the extension: filesystem and visible within EOS. Puppet could ensure the file exists in Flash: (/mnt/flash), then use eAPI or FastCli to send copy flash:<extension> extension:
.
Hi, I played around with the idea to update the rbeapi.rpm via puppet. I cannot use the rbeapi it self, because than I am limited to updates and cannot to an initial install. Therefore I tired to warp it into FastCli -c ‚foo bar‘ commands, which I put into a shell script. If I execute the script it works fine, but if the puppet agent executes it is not able to connect through the FastCli call.
Therefore I used strace to see what is happening.
Puppet run
execve("/usr/bin/FastCli", ["/usr/bin/FastCli", "-p", "15", "-c", "show extension"], [/* 15 vars /]) = 0 .. execve("/usr/bin/fastclient", ["fastclient", "-r", "FastCli", "-t", "CliPoolMgr/ar", "-p", "15", "-c", "show extension"], [/ 16 vars */]) = 0 .. connect(6, {sa_family=AF_FILE, path=@"/fastclient/CliPoolMgr/ar"}, 28) = -1 ECONNREFUSED (Connection refused) ..
If I run it as the root user it works.
execve("/usr/bin/FastCli", ["/usr/bin/FastCli", "-p", "15", "-c", "show extension"], [/* 22 vars /]) = 0 .. execve("/usr/bin/fastclient", ["fastclient", "-r", "FastCli", "-t", "CliPoolMgr/ar", "-p", "15", "-c", "show extension"], [/ 23 vars */]) = 0 .. connect(6, {sa_family=AF_FILE, path=@"/fastclient/CliPoolMgr/ar"}, 28) = 0
Does anyone have an idea how to solve this?
Puppet:
exec { 'update_extension': subscribe => File['/usr/local/sbin/update_extension.sh'], refreshonly => true, user => 'root', group => 'root', logoutput => true, command => '/usr/local/sbin/update_extension.sh', }
script:
!/bin/bash -x
/usr/bin/strace /usr/bin/FastCli -p 15 -c 'show extension'