Install into /opt/ansible when running as root

This commit is contained in:
Anthony Rose 2021-02-22 09:50:04 +00:00
parent 5a56df3d36
commit 08c26311b2

View file

@ -14,12 +14,20 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if [ $(id -u) -eq 0 ]; then
install_path=/opt/ansible
bin_path=/usr/local/bin
else
install_path="$HOME/opt/ansible"
bin_path="$HOME/bin"
fi
pipinstall () { pipinstall () {
./bin/pip install --upgrade $1 ./bin/pip install --upgrade $1
} }
create_link () { create_link () {
ln -sf "../opt/ansible/bin/$1" "$HOME/bin/$1" ln -sf "$install_path/bin/$1" "$bin_path/$1"
} }
py3cmd="$(command -v python3)" py3cmd="$(command -v python3)"
@ -31,17 +39,17 @@ else
fi fi
if [ ! -x "$HOME/opt/ansible/bin/ansible-playbook" ]; then if [ ! -x "$HOME/opt/ansible/bin/ansible-playbook" ]; then
python3 -m venv "$HOME/opt/ansible" || exit 1 python3 -m venv "$install_path" || exit 1
fi fi
pushd "$HOME/opt/ansible" pushd "$install_path"
pipinstall pip pipinstall pip
pipinstall wheel pipinstall wheel
pipinstall ansible pipinstall ansible
popd popd
if [ ! -d "$HOME/bin" ]; then if [ ! -d "$bin_path" ]; then
mkdir "$HOME/bin" mkdir "$bin_path"
fi fi
for command in \ for command in \