repo_setup: Add sudo to specific commands for non-root running

Only a few lines in the repo_setup.sh.j2 template require sudo for
non-root execution. This commit prepends sudo to those commands.

Change-Id: I35f7ab57f6af26fb84e4da7003e071125905b922
This commit is contained in:
Ben Kero 2017-01-06 01:18:34 +08:00
parent 9f9f5c0fde
commit c21542baf0
2 changed files with 10 additions and 10 deletions

View File

@ -9,13 +9,13 @@ stable:
- mitaka - mitaka
- liberty - liberty
repo_cmd_before: | repo_cmd_before: |
yum install -y yum-plugin-priorities; sudo yum install -y yum-plugin-priorities;
yum clean all; sudo yum clean all;
rm -rf /etc/yum.repos.d/delorean*; sudo rm -rf /etc/yum.repos.d/delorean*;
rm -rf /etc/yum.repos.d/*.rpmsave; sudo rm -rf /etc/yum.repos.d/*.rpmsave;
repo_cmd_after: | repo_cmd_after: |
yum repolist; sudo yum repolist;
yum update -y sudo yum update -y
# Repositories definitions # Repositories definitions
repos: repos:

View File

@ -18,7 +18,7 @@ else
sed -i "s/priority=.*/priority={{ repo.priority }}/g" /tmp/repo_role_tmp/{{ repo.filename }} sed -i "s/priority=.*/priority={{ repo.priority }}/g" /tmp/repo_role_tmp/{{ repo.filename }}
fi fi
{% endif %} {% endif %}
cp -f /tmp/repo_role_tmp/{{ repo.filename }} /etc/yum.repos.d/ sudo cp -f /tmp/repo_role_tmp/{{ repo.filename }} /etc/yum.repos.d/
{% endif %} {% endif %}
{% if repo.type == 'generic' %} {% if repo.type == 'generic' %}
@ -41,11 +41,11 @@ enabled={{ repo.enabled|default('1') }}
{% if repo.down_url is defined %}# trunk_hash=${HASH:-} {% if repo.down_url is defined %}# trunk_hash=${HASH:-}
{% endif %} {% endif %}
EOF EOF
cp -f /tmp/repo_role_tmp/{{ repo.filename }} /etc/yum.repos.d/ sudo cp -f /tmp/repo_role_tmp/{{ repo.filename }} /etc/yum.repos.d/
{% endif %} {% endif %}
{% if repo.type == 'package' %} {% if repo.type == 'package' %}
{{ repo.custom_cmd|default('yum install -y') }} {{ repo.pkg_name|default(repo.pkg_url) }} {{ repo.custom_cmd|default('sudo yum install -y') }} {{ repo.pkg_name|default(repo.pkg_url) }}
{% endif %} {% endif %}
{% endif %} {% endif %}