cisagov / ansible-role-amazon-ssm-agent

An Ansible role for installing aws/amazon-ssm-agent
Creative Commons Zero v1.0 Universal
8 stars 4 forks source link

Role fails when applied to an Ubuntu AMI #56

Closed jsf9k closed 1 month ago

jsf9k commented 3 months ago

🐛 Summary

This Ansible role fails when building Ubuntu-based AMIs. See this build, for instance.

The problem is that the agent is pre-installed via snap on the official Ubuntu AMIs for recent versions of Ubuntu. In fact, according to the documentation from AWS, the SSM Agent should be installed via snap on all the Ubuntu versions that we support.

Expected behavior

I expect the role to cleanly install the SSM agent when building Ubuntu-based AMIs.

Any helpful log output or screenshots

2024-07-08T21:35:50Z:     amazon-ebs.nessus: TASK [amazon_ssm_agent : Download and install amazon-ssm-agent deb package] ****
2024-07-08T21:35:54Z:     amazon-ebs.nessus: fatal: [default]: FAILED! => {"changed": false, "msg": "dpkg --force-confdef --force-confold -i /home/ubuntu/.ansible/tmp/ansible-tmp-1720474550.5386984-3234-49069457483534/amazon-ssm-agent_zlbs2yg.deb failed", "stderr": "dpkg: error processing archive /home/ubuntu/.ansible/tmp/ansible-tmp-1720474550.5386984-3234-49069457483534/amazon-ssm-agent_zlbs2yg.deb (--install):\n new amazon-ssm-agent package pre-installation script subprocess returned error exit status 1\nErrors were encountered while processing:\n /home/ubuntu/.ansible/tmp/ansible-tmp-1720474550.5386984-3234-49069457483534/amazon-ssm-agent_zlbs2yg.deb\n", "stderr_lines": ["dpkg: error processing archive /home/ubuntu/.ansible/tmp/ansible-tmp-1720474550.5386984-3234-49069457483534/amazon-ssm-agent_zlbs2yg.deb (--install):", " new amazon-ssm-agent package pre-installation script subprocess returned error exit status 1", "Errors were encountered while processing:", " /home/ubuntu/.ansible/tmp/ansible-tmp-1720474550.5386984-3234-49069457483534/amazon-ssm-agent_zlbs2yg.deb"], "stdout": "Selecting previously unselected package amazon-ssm-agent.\n(Reading database ... 109326 files and directories currently installed.)\nPreparing to unpack .../amazon-ssm-agent_zlbs2yg.deb ...\nPreparing for install\n-> Systemd detected\nactive\namazon-ssm-agent  3.3.131.0  7994   latest/stable/…  aws**        classic\n-> Amazon-ssm-agent is installed in this instance by snap, please use snap to update or uninstall.\n", "stdout_lines": ["Selecting previously unselected package amazon-ssm-agent.", "(Reading database ... 109326 files and directories currently installed.)", "Preparing to unpack .../amazon-ssm-agent_zlbs2yg.deb ...", "Preparing for install", "-> Systemd detected", "active", "amazon-ssm-agent  3.3.131.0  7994   latest/stable/…  aws**        classic", "-> Amazon-ssm-agent is installed in this instance by snap, please use snap to update or uninstall."]}