aws / amazon-ssm-agent

An agent to enable remote management of your EC2 instances, on-premises servers, or virtual machines (VMs).
https://aws.amazon.com/systems-manager/
Apache License 2.0
1.05k stars 324 forks source link

Ability to customise DefaultDocumentWorker #76

Closed cknowles closed 5 years ago

cknowles commented 6 years ago

Is it possible to customise the value for DefaultDocumentWorker on linux?

By default it appears to be hard coded to /usr/bin: https://github.com/aws/amazon-ssm-agent/blob/e092980b261c432156f738dc1531666bf8277679/agent/appconfig/constants_unix.go#L79

We're trying to deploy on Container Linux based on this blog post. It's not a current supported OS, although the agent does work fine if we rebuild after changing that value. The reason it needs to be different is on Container Linux /usr is read only to allow for OS updates.

shengmiw commented 6 years ago

we currently don't support customizing binary paths.

hui-yang commented 6 years ago

I have the same request for a different use case. I simply compiled amazon-ssm-agent from source on an unsupported OS, and I had to move ssm-document-worker binary from build directory to /usr/bin, because the reference is hardcoded.

Do you support this use case? If yes, the Readme should mention it https://github.com/aws/amazon-ssm-agent#building-and-running-from-source If not, do you suggested always create a release package?

jhmartin commented 6 years ago

Same issue here; realizing CoreOS is not a supported OS but the hardcoding is unnecessarily strict.

jhmartin commented 6 years ago

FYI the last release before the worker process entered was https://github.com/aws/amazon-ssm-agent/releases/tag/2.0.952.0.

https://amazon-ssm-us-east-1.s3.amazonaws.com/2.0.952.0/linux_amd64/amazon-ssm-agent.rpm

jpadilla commented 6 years ago

Just ran into this as well. Any workarounds?

cknowles commented 6 years ago

@jpadilla for what it's worth, we augmented the script from the blog post I linked above with this:

sed -i "s+/usr/bin/ssm-document-worker+$BIN_DIR/ssm-document-worker+g" agent/appconfig/constants_unix.go

That's not to say all agent actions work as the OS is still not supported, but at least now it runs and shell script can be executed and audited via SSM.

jhmartin commented 6 years ago

A custom build is certainly an option, but it is so much cleaner if it is a native configurable.

jinal--shah commented 6 years ago

@c-knowles @jpadilla @jhmartin @hui-yang - I have release binaries on my fork which lets you set $SSM_DOCUMENT_WORKER_PATH at agent run-time:

https://github.com/opsgang/amazon-ssm-agent/

Effectively you can install the agent and ssm doc worker binaries anywhere on the filesystem.

You can download the built releases (these work on CoreOS amongst other linux amd4s) from here: https://github.com/opsgang/amazon-ssm-agent/releases

I will be keeping this in-sync with the upstream - builds of the binaries are automated on a release.

Hope its of use ...

jhmartin commented 6 years ago

@jinal--shah I suggest submitting a PR here with that, if nothing else AWS then can't complain about the work necessary to enable it.

mumoshu commented 6 years ago

As of today, DefaultDocumentWorker is a var and I suppose it is ok to be modified at runtime. It is handling ubuntu w/ snap in that way.

mumoshu commented 6 years ago

@c-knowles @jpadilla @jhmartin Just submitted #101 for this. Would it work for you guys?

@jinal--shah's I was able to notice that it was just a matter of adding 4 lines today, thanks to the last commit in your fork. Thanks for that 🙏

hiimtu commented 5 years ago

Should be resolved: https://github.com/aws/amazon-ssm-agent/commit/bc7e78017a7802854fb9ddf313ca053a20e6a471 thanks @bdwyertech