Page MenuHomePhabricator

Allow analytics-search-users members to sudo as the airflow user
Closed, ResolvedPublic

Description

In T236180 the Search team is trying to bootstrap an Apache Airflow service (https://airflow.apache.org/).
In order to properly manage it, they'd need to be able to impersonate the airflow system user and perform some related sudo command (to restart/start/stop the service, etc..) on an-airflow1001.eqiad.wmnet (Ganeti VM in the Analytics VLAN).

Currently the proposal is https://gerrit.wikimedia.org/r/#/c/operations/puppet/+/552304/1/modules/admin/data/data.yaml

Caveat: the analytics-search-users group is deployed to all the analytics hosts. We (as Analytics) don't have any Airflow service yet, but we might in the future. I can see two paths forward:

  1. We review/merge this change now and then revise the permissions in the future if needed.
  2. We create a new group called airflow-search-users (or similar) that is only deployed to an-airflow1001.eqiad.wmnet, more tedious but probably a little bit more clean from the user perms point of view.

Let me know what you think about it :)

Event Timeline

Since this instance is maintained by the search team, I think re-using analytics-search-users makes sense to me. We can re-evaluate that when if/we run an official airflow.

Since this instance is maintained by the search team, I think re-using analytics-search-users makes sense to me. We can re-evaluate that when if/we run an official airflow.

The only drawback is that analytics-search-users is not deployed in various places, so adding sudo perms to that group will automatically push them on various hosts. No harm, just wanted to bring it up :)

Change 552613 had a related patch set uploaded (by Dzahn; owner: Dzahn):
[operations/puppet@production] analytics/admins: create admin group and for for airflor, apply on an-airflow1001

https://gerrit.wikimedia.org/r/552613

probably a little bit more clean from the user perms point of view.

Yes please, let's create a new admin group.

adding sudo perms to that group will automatically push them on various hosts

Yea, let's avoid that.

more tedious

Yea, but you need a role for that host anyways to apply the admin group or we start using ./hosts/ and so on. Let's just do it right away?

I made https://gerrit.wikimedia.org/r/c/operations/puppet/+/552613

That also adds the host to the analytics cluster in Icinga, installs the base packages and gives the people access.

And then you can skip:

re-evaluate that when if/we run an official airflow

Hope that is helpful.

Change 552613 merged by Elukey:
[operations/puppet@production] Create airflow-search-admins admin group

https://gerrit.wikimedia.org/r/552613

The group has been created and request was approved in SRE meeting.

It needs merge of https://gerrit.wikimedia.org/r/c/operations/puppet/+/552304 though. (which looks fine to me, but the units listed in the sudo privileges don't seem to exist on an-airflow1001 yet).

[an-airflow1001:~] $ id ebernhardson
uid=3088(ebernhardson) gid=500(wikidev) groups=500(wikidev),816(airflow-search-admins)

[an-airflow1001:~] $ grep airflow /etc/group
airflow:x:1001:
airflow-search-admins:x:816:ebernhardson,dcausse,gehel,bearloga,chelsyx

[an-airflow1001:~] $ sudo cat /etc/sudoers.d/airflow-search-admins 
# This file is managed by Puppet!

%airflow-search-admins ALL = NOPASSWD: /usr/sbin/service airflow-webserver *
%airflow-search-admins ALL = NOPASSWD: /usr/sbin/service airflow-scheduler *
%airflow-search-admins ALL = NOPASSWD: /bin/systemctl start airflow-scheduler
%airflow-search-admins ALL = NOPASSWD: /bin/systemctl restart airflow-scheduler
%airflow-search-admins ALL = NOPASSWD: /bin/systemctl stop airflow-scheduler
%airflow-search-admins ALL = NOPASSWD: /bin/systemctl start airflow-webserver
%airflow-search-admins ALL = NOPASSWD: /bin/systemctl stop airflow-webserver
%airflow-search-admins ALL = NOPASSWD: /bin/systemctl restart airflow-webserver
%airflow-search-admins ALL = (airflow) NOPASSWD: /srv/deployment/search/airflow/venv/bin/airflow *
Dzahn removed a project: Patch-For-Review.

I merged the change by @EBernhardson which added the new group on an-airflow1001. Puppet has created the users and sudo privileges for them as above. Please comment if something is missing.