awslogs-agent-setup.py没有在Ubuntu 17.10上工作(巧妙)

时间:2018-02-15 22:44:34

标签: amazon-web-services ubuntu amazon-cloudwatch ubuntu-17.10

这适用于ubuntu 16.04,但不适用于17.10

semantic

我注意到在此过程的早期,在AWS样板中,它无法安装libyaml-dev,但不确定这是否是唯一的问题。

2 个答案:

答案 0 :(得分:2)

我发布后总能找到答案......

这是我修改过的CF模板命令:

    050_install_awslogs:
      command: !Sub 
        "/bin/bash -x\n
        exec >>/var/log/cf_050_install_awslogs.log 2>&1 \n
        echo 050_install_awslogs...\n
        set -xe\n
        # Get the CloudWatch Logs agent\n
        mkdir /opt/awslogs\n
        cd /opt/awslogs\n
        # Needed for python3 in 17.10\n
        apt-get install -y libyaml-dev python-dev \n
        pip3 install awscli-cwlogs\n
        # avoid it complaining about not having /var/awslogs/bin/aws binary\n
        if [ ! -d /var/awslogs/bin ] ; then\n
          mkdir -p /var/awslogs/bin\n
          ln -s /usr/local/bin/aws /var/awslogs/bin/aws\n
        fi\n
        curl https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py -O\n
        chmod +x ./awslogs-agent-setup.py\n
        # Hack for python 3.6 & old awslogs-agent-setup.py\n
        sed -i 's/3,6/3,7/' awslogs-agent-setup.py\n
        ./awslogs-agent-setup.py -n -c /etc/awslogs/awslogs.conf -r ${AWS::Region}\n
        echo 050_install_awslogs end\n
        "

不完全确定是否需要创建目录但我希望这是一个临时案例,很快就会解决,因为仍然需要捏造python 3.6兼容性检查。

它也可以使用python 2.7进行安装,但感觉就像在这一点上倒退一样,因为17.10的基本原理是python 3.6。

将yaml包和目录创建的想法归功于https://forums.aws.amazon.com/thread.jspa?threadID=265977,但我更愿意避免使用easy_install。

答案 1 :(得分:0)

我在Ubuntu 18.04上有类似的问题。

Instruction from AWS独立安装适用于我的情况。

To download and run it standalone, use the following commands and follow the prompts:

curl https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py -O
curl https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/AgentDependencies.tar.gz -O
tar xvf AgentDependencies.tar.gz -C /tmp/
sudo python ./awslogs-agent-setup.py --region us-east-1 --dependency-path /tmp/AgentDependencies