awslogs-agent-setup.py not working on Ubuntu 17.10 (artful)

旧城冷巷雨未停 提交于 2019-12-11 07:36:54

问题


This works fine on ubuntu 16.04, but not on 17.10

+ curl https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py -O
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
^M  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0^M100 56093  100 56093    0     0  56093      0  0:00:01 --:--:--  0:00:01 98929
+ chmod +x ./awslogs-agent-setup.py
+ ./awslogs-agent-setup.py -n -c /etc/awslogs/awslogs.conf -r us-west-2

Step 1 of 5: Installing pip ...^[[0mlibyaml-dev does not exist in system ^[[0m^[[92mDONE^[[0m

Step 2 of 5: Downloading the latest CloudWatch Logs agent bits ... ^[[0mTraceback (most recent call last):
  File "./awslogs-agent-setup.py", line 1317, in <module>
    main()
  File "./awslogs-agent-setup.py", line 1313, in main
    setup.setup_artifacts()
  File "./awslogs-agent-setup.py", line 858, in setup_artifacts
    self.install_awslogs_cli()
  File "./awslogs-agent-setup.py", line 570, in install_awslogs_cli
    subprocess.call([AWSCLI_CMD, 'configure', 'set', 'plugins.cwlogs', 'cwlogs'], env=DEFAULT_ENV)
  File "/usr/lib/python2.7/subprocess.py", line 168, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 390, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1025, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

I noticed that earlier on in the process, in the AWS boilerplate it failed to install libyaml-dev but not sure if that's the only problem.


回答1:


Always find the answer right after I post it...

Here's my modified CF template command:

    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
        "

Not entirely sure about the need for the dir creation but I expect this is a temporary case that will get resolved soon as one still needs to fudge the python 3.6 compatibility check.

it may be installable using python 2.7 as well, but that felt like going backwards at this point as the my rationale for 17.10 was python 3.6.

Credit for the yaml package and dir creation idea to https://forums.aws.amazon.com/thread.jspa?threadID=265977 but I prefer to avoid easy_install.




回答2:


I had similar issue on Ubuntu 18.04.

Instruction from AWS for standalone install worked for my case.

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


来源:https://stackoverflow.com/questions/48817525/awslogs-agent-setup-py-not-working-on-ubuntu-17-10-artful

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!