Skip to content

Conversation

@mikedickey
Copy link
Contributor

This PR enables running in unprivileged mode when run as the splunk user account. The splunk user is now part of the ansible group and able to run the ansible playbooks itself at startup, but unlike ansible, it has no sudo capabilities at startup time.

Note that you currently must explicitly set SPLUNK_HOME_OWNERSHIP_ENFORCEMENT to false when running as the splunk user, otherwise it will fail due to lack of permissions.

Note that there are limitations, beyond just being unable to "correct" permission for volume mounts. Any features requiring elevated permissions, such as install JDK or other packages, will not work when running as the splunk user.

The defaults are left unchanged. By default, it will still run as the ansible user and the behavior should be the same as before.

user account. The splunk user is now part of the ansible group and
able to run the ansible playbooks itself at startup, but unlike ansible,
it has no sudo capabilities at startup time.

Note that you currently must explicitly set SPLUNK_HOME_OWNERSHIP_ENFORCEMENT
to false when running as the splunk user, otherwise it will fail due to
lack of permissions.

Note that there are limitations, beyond just being unable to "correct"
permission for volume mounts. Any features requiring elevated permissions,
such as install JDK or other packages, will not work when running as the
splunk user.

The defaults are left unchanged. By default, it will still run as the
ansible user and the behavior should be the same as before.
@mikedickey
Copy link
Contributor Author

Also note I made some indenting fixes in entrypoint.sh so that it's (I think) all using tabs now

ascii art formatting and finish indenting consistency.

Merged in same changes for running as splunk user to universal
forwarder Dockerfile and entrypoint.sh.

Updated whitespace in universal forwarder entrypoint.sh to also use
tables for consistency.
@nwang92
Copy link
Contributor

nwang92 commented Aug 19, 2019

Overall, this follows what @lephino and I came up with last Friday so I don't have any real issues with it. I can add some tests for any upgrade functionality so we have that in our pipeline in the future.

prep_ansible() {
cd ${SPLUNK_ANSIBLE_HOME}
if [ `whoami` == "${SPLUNK_USER}" ]; then
sed -i -e "s,^become\\s*=.*,become = false," ansible.cfg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small thing here that I don't quite like is that our ansible.cfg as shown in the repo is not actually representative of the ansible.cfg during execution under a different user. But I suppose this is a necessary evil at the moment so as long as it's documented, it should be alright.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was hoping that become_user when you are that user is a noop, but unfortuantely that is not the case. Without explicitly disabling it here, ansible bombs out at startup with complaints that it cannot use sudo without a password.

@bb03 bb03 merged commit 7a28b42 into develop Aug 20, 2019
@sayeedc
Copy link

sayeedc commented Sep 4, 2019

I’ve encountered issues running Splunk SE and UF on Openshift in unprivileged mode. When will this PR be put into an image release on either the Redhat container catalog or Docker Hub?

@mikedickey
Copy link
Contributor Author

I’ve encountered issues running Splunk SE and UF on Openshift in unprivileged mode. When will this PR be put into an image release on either the Redhat container catalog or Docker Hub?

Hi Sayeed, this should be included in the edge containers (which are built nightly), and will be included with the next release (7.3.2?). For OpenShift, I'd recommend trying specifically splunk/splunk:edge-redhat.

@sayeedc
Copy link

sayeedc commented Sep 5, 2019

I’ve encountered issues running Splunk SE and UF on Openshift in unprivileged mode. When will this PR be put into an image release on either the Redhat container catalog or Docker Hub?

Hi Sayeed, this should be included in the edge containers (which are built nightly), and will be included with the next release (7.3.2?). For OpenShift, I'd recommend trying specifically splunk/splunk:edge-redhat.

Hi Mike. Thanks for the info. I'll test out the edge image. Is there an edge-redhat image for the the universal forwarder?

mikedickey pushed a commit to splunk/splunk-operator that referenced this pull request Oct 10, 2019
splunk user with fsGroup set to splunk group. This ensures that all
the PVC's created for the pod will be group owned appropriately,
so that our splunk user is able to write to them.

This works in conjunction with the docker-splunk container changes
that allow it to run unpriviledged: splunk/docker-splunk#222
It will not work with any containers that do not include this change.

Removed the now unused GetSplunkDeployment method

Made a minor logging fix that was printing out a data type
@nwang92 nwang92 deleted the no-sudo-when-running-as-splunk branch October 29, 2019 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants