Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

No sudo with common commands? #60

Closed
VikParuchuri opened this issue May 13, 2013 · 3 comments
Closed

No sudo with common commands? #60

VikParuchuri opened this issue May 13, 2013 · 3 comments

Comments

@VikParuchuri
Copy link
Contributor

I am periodically merging master into my branch that configures the ml api, and the biggest issue is the removal of sudo in the common playbook. How is the lack of sudo working?

For example, this will fail:

- name: Create data dir
  file: path={{ app_base_dir }}/data state=directory owner=root group=root
  tags:
  - pre_install

This will succeed:

- name: Create data dir
  file: path={{ app_base_dir }}/data state=directory owner=root group=root
  sudo: True
  tags:
  - pre_install

Am I doing something wrong with users or the ansible command?

I am running:

ansible-playbook mlapi_sandbox.yml -i ./ec2.py -c ssh --user=ubuntu -v

This is happening in the aws-sandbox account, and the ansible command is bring run on a vpc.

@jarv
Copy link
Contributor

jarv commented May 13, 2013

by default all commands will be run as --user and it won't use sudo by
default, in your example the command needs to be run as root.
In your top level playbook you can tell ansible to always use sudo which
might be simpler than setting sudo for every task.
http://ansible.cc/docs/playbooks.html#playbook-language-example

On Mon, May 13, 2013 at 5:52 PM, VikParuchuri notifications@github.comwrote:

I am periodically merging master into my branch that configures the ml
api, and the biggest issue is the removal of sudo in the common playbook.
How is the lack of sudo working?

For example, this will fail:

  • name: Create data dir
    file: path={{ app_base_dir }}/data state=directory owner=root group=root
    tags:
    • pre_install

This will succeed:

  • name: Create data dir
    file: path={{ app_base_dir }}/data state=directory owner=root group=root
    sudo: True
    tags:
    • pre_install

Am I doing something wrong with users or the ansible command?

I am running:

ansible-playbook mlapi_sandbox.yml -i ./ec2.py -c ssh --user=ubuntu -v

This is happening in the aws-sandbox account.


Reply to this email directly or view it on GitHubhttps://github.com/edx/issues/60
.

@jrbl
Copy link
Contributor

jrbl commented May 13, 2013

So, sudo isn't an activity variable, it's a playbook variable. So once it's
set by any activity, it's set for all activities.

It was dropped out of common because I felt it should be defined as close
as possible to the scope in which it applied, e.g., edx_prod.yml,
edx_stage.yml, oc edx_custom.yml. So in your case, Vik, I'd define it
after the - host line in mlapi_sandbox.yml, like so:

  • host tag_my_boxes
  • sudo: True
  • vars yadda yadda yadda

HTH,
Joe

On Mon, May 13, 2013 at 2:52 PM, VikParuchuri notifications@github.comwrote:

I am periodically merging master into my branch that configures the ml
api, and the biggest issue is the removal of sudo in the common playbook.
How is the lack of sudo working?

For example, this will fail:

  • name: Create data dir
    file: path={{ app_base_dir }}/data state=directory owner=root group=root
    tags:
    • pre_install

This will succeed:

  • name: Create data dir
    file: path={{ app_base_dir }}/data state=directory owner=root group=root
    sudo: True
    tags:
    • pre_install

Am I doing something wrong with users or the ansible command?

I am running:

ansible-playbook mlapi_sandbox.yml -i ./ec2.py -c ssh --user=ubuntu -v

This is happening in the aws-sandbox account.


Reply to this email directly or view it on GitHubhttps://github.com/edx/issues/60
.

@VikParuchuri
Copy link
Contributor Author

Thanks a lot, John and Joe!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants