Bug 781580

Summary: audrey agent is not running on rhel6.2 ec2 instances
Product: [Retired] CloudForms Cloud Engine Reporter: dgao
Component: imagefactoryAssignee: Ian McLeod <imcleod>
Status: CLOSED CURRENTRELEASE QA Contact: Brad P. Crochet <brad>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 1.0.0CC: akarol, brad, dajohnso, deltacloud-maint, dgao, ssachdev, whayutin
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-30 17:14:41 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description dgao 2012-01-13 19:20:32 UTC
When launching a RHEL6.2 EC2 instance that have audrey, the agent does not run after bootup. Upon further investigation, the following line is missing from /etc/rc.local which would of kicked off the audrey process:


# This conditionally runs Audrey if it exists
[ -f /usr/bin/audrey ] && /usr/bin/audrey

Comment 1 dgao 2012-01-13 19:33:38 UTC
/etc/rc.local found on the RHEL6.2 ec2 instance



#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
if [ ! -d /root/.ssh ] ; then
    mkdir -p /root/.ssh
    chmod 0700 /root/.ssh
    restorecon /root/.ssh
fi

# bz 707364
if [ ! -f /etc/blkid/blkid.tab ] ; then
    blkid /dev/xvda &>/dev/null
fi 

ATTEMPTS=5
FAILED=0
# Fetch public key using HTTP
while [ ! -f /root/.ssh/authorized_keys ]; do
    curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key > /tmp/aws-key 2>/dev/null
    if [ $? -eq 0 ]; then
        cat /tmp/aws-key >> /root/.ssh/authorized_keys
        chmod 0600 /root/.ssh/authorized_keys
        restorecon /root/.ssh/authorized_keys
        rm -f /tmp/aws-key
        echo "Successfully retrieved AWS public key from instance metadata"
    else
        FAILED=$(($FAILED + 1))
        if [ $FAILED -ge $ATTEMPTS ]; then
            echo "Failed to retrieve AWS public key after $FAILED attempts, quitting"
            break
        fi
        echo "Could not retrieve AWS public key (attempt #$FAILED/$ATTEMPTS), retrying in 5 seconds..."
        sleep 5
    fi
done

Comment 2 jrd 2012-01-16 15:34:25 UTC
It wasn't clear to me whether this was a factory or audrey bug.  Ian, assess?

Comment 3 Ian McLeod 2012-01-17 20:31:16 UTC
Factory bug-ish.

In truth, I think we should have the Audrey client-side package do this (or something similar) for itself.  However, to avoid any big changes prior to this release, I've fixed up the EC2 snapshot builders to add in the required line.

The fix can be found here:

https://github.com/aeolusproject/imagefactory/tree/rhel_audrey

As this commit:

https://github.com/aeolusproject/imagefactory/commit/d3fb23771dddaa6e4b284350fe18399200d22aad

Switching to ON_QA

Comment 4 dgao 2012-01-20 14:43:55 UTC
[root@domU-12-31-39-0B-88-D1 log]# cat /etc/rc.local 
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
if [ ! -d /root/.ssh ] ; then
    mkdir -p /root/.ssh
    chmod 0700 /root/.ssh
    restorecon /root/.ssh
fi

# bz 707364
if [ ! -f /etc/blkid/blkid.tab ] ; then
    blkid /dev/xvda &>/dev/null
fi 

ATTEMPTS=5
FAILED=0
# Fetch public key using HTTP
while [ ! -f /root/.ssh/authorized_keys ]; do
    curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key > /tmp/aws-key 2>/dev/null
    if [ $? -eq 0 ]; then
        cat /tmp/aws-key >> /root/.ssh/authorized_keys
        chmod 0600 /root/.ssh/authorized_keys
        restorecon /root/.ssh/authorized_keys
        rm -f /tmp/aws-key
        echo "Successfully retrieved AWS public key from instance metadata"
    else
        FAILED=$(($FAILED + 1))
        if [ $FAILED -ge $ATTEMPTS ]; then
            echo "Failed to retrieve AWS public key after $FAILED attempts, quitting"
            break
        fi
        echo "Could not retrieve AWS public key (attempt #$FAILED/$ATTEMPTS), retrying in 5 seconds..."
        sleep 5
    fi
done

# This conditionally runs Audrey if it exists
[ -f /usr/bin/audrey ] && /usr/bin/audrey
[root@domU-12-31-39-0B-88-D1 log]# rpm -q aeolus-audrey-agent
aeolus-audrey-agent-0.4.3-1.el6.noarch
[root@domU-12-31-39-0B-88-D1 log]# ls /var/log/audrey.log 
/var/log/audrey.log
[root@domU-12-31-39-0B-88-D1 log]#