Install ansible from pip by default
Legacy behavior can be enabled by running export ANSIBLE_INSTALL_SOURCE=apt Change-Id: I9fed27340ec8869c6459792ffaff13f77473c738
This commit is contained in:
parent
2d517fccf1
commit
6fdac9e4cc
|
@ -36,7 +36,9 @@ OS_SPECIFIC_DEFAULTS_SRC="${BASH_SOURCE%/*}/../kargo/${OS_SPECIFIC_DEFAULTS_YAML
|
||||||
LOG_LEVEL=${LOG_LEVEL:--v}
|
LOG_LEVEL=${LOG_LEVEL:--v}
|
||||||
ANSIBLE_TIMEOUT=${ANSIBLE_TIMEOUT:-600}
|
ANSIBLE_TIMEOUT=${ANSIBLE_TIMEOUT:-600}
|
||||||
|
|
||||||
required_ansible_version="2.1.0"
|
# Valid sources: pip, apt
|
||||||
|
ANSIBLE_INSTALL_SOURCE=pip
|
||||||
|
required_ansible_version="2.2.0"
|
||||||
|
|
||||||
function collect_info {
|
function collect_info {
|
||||||
# Get diagnostic info and store it as the logs.tar.gz at the admin node
|
# Get diagnostic info and store it as the logs.tar.gz at the admin node
|
||||||
|
@ -129,7 +131,7 @@ function with_ansible {
|
||||||
|
|
||||||
until admin_node_command \
|
until admin_node_command \
|
||||||
ANSIBLE_CONFIG=$ADMIN_WORKSPACE/utils/kargo/ansible.cfg \
|
ANSIBLE_CONFIG=$ADMIN_WORKSPACE/utils/kargo/ansible.cfg \
|
||||||
/usr/bin/ansible-playbook \
|
ansible-playbook \
|
||||||
--ssh-extra-args "-A\ -o\ StrictHostKeyChecking=no" -u ${ADMIN_USER} -b \
|
--ssh-extra-args "-A\ -o\ StrictHostKeyChecking=no" -u ${ADMIN_USER} -b \
|
||||||
-e ansible_ssh_user=${ADMIN_USER} \
|
-e ansible_ssh_user=${ADMIN_USER} \
|
||||||
--become-user=root -i $ADMIN_WORKSPACE/inventory/inventory.cfg \
|
--become-user=root -i $ADMIN_WORKSPACE/inventory/inventory.cfg \
|
||||||
|
@ -190,7 +192,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install missing packages on the host running this script
|
# Install missing packages on the host running this script
|
||||||
if ! type sshpass > /dev/null; then
|
if ! type sshpass 2>&1 > /dev/null; then
|
||||||
sudo apt-get update && sudo apt-get install -y sshpass
|
sudo apt-get update && sudo apt-get install -y sshpass
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -217,9 +219,7 @@ admin_node_command mkdir -p $ADMIN_WORKSPACE/utils/kargo
|
||||||
tar cz ${BASH_SOURCE%/*}/../kargo | admin_node_command tar xzf - -C $ADMIN_WORKSPACE/utils/
|
tar cz ${BASH_SOURCE%/*}/../kargo | admin_node_command tar xzf - -C $ADMIN_WORKSPACE/utils/
|
||||||
|
|
||||||
echo "Setting up ansible and required dependencies..."
|
echo "Setting up ansible and required dependencies..."
|
||||||
installed_ansible_version=$(admin_node_command dpkg-query -W -f='\${Version}\\n' ansible || echo "0.0")
|
if ! admin_node_command type ansible 2>&1 > /dev/null; then
|
||||||
if ! admin_node_command type ansible > /dev/null || \
|
|
||||||
dpkg --compare-versions "$installed_ansible_version" "lt" "$required_ansible_version"; then
|
|
||||||
# Wait for apt lock in case it is updating from cron job
|
# Wait for apt lock in case it is updating from cron job
|
||||||
case $ADMIN_NODE_BASE_OS in
|
case $ADMIN_NODE_BASE_OS in
|
||||||
ubuntu)
|
ubuntu)
|
||||||
|
@ -245,7 +245,15 @@ if ! admin_node_command type ansible > /dev/null || \
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
wait_for_apt_lock_release
|
wait_for_apt_lock_release
|
||||||
with_retries admin_node_command -- sudo apt-get install -y ansible python-netaddr git
|
if [[ "$ANSIBLE_INSTALL_SOURCE" == "apt" ]]; then
|
||||||
|
with_retries admin_node_command -- sudo apt-get install -y ansible python-netaddr git
|
||||||
|
elif [[ "$ANSIBLE_INSTALL_SOURCE" == "pip" ]]; then
|
||||||
|
with_retries admin_node_command -- sudo apt-get install -y python-netaddr git libssl-dev
|
||||||
|
with_retries admin_node_command -- sudo pip install --upgrade ansible==$required_ansible_version
|
||||||
|
else
|
||||||
|
echo "ERROR: Unknown Ansible install source: ${ANSIBLE_INSTALL_SOURCE}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Checking out kargo playbook..."
|
echo "Checking out kargo playbook..."
|
||||||
|
|
|
@ -12,6 +12,24 @@
|
||||||
state: directory
|
state: directory
|
||||||
owner: "{{ansible_ssh_user}}"
|
owner: "{{ansible_ssh_user}}"
|
||||||
|
|
||||||
|
- name: Configure logs | ensure config dir
|
||||||
|
file:
|
||||||
|
path: "{{conf_file | dirname}}"
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0755
|
||||||
|
recurse: yes
|
||||||
|
|
||||||
|
- name: Configure logs | ensure config file
|
||||||
|
get_url:
|
||||||
|
url: https://raw.githubusercontent.com/ansible/ansible/stable-2.2/examples/ansible.cfg
|
||||||
|
dest: "{{conf_file}}"
|
||||||
|
force: no
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
- name: Configure logs | get plugins
|
- name: Configure logs | get plugins
|
||||||
git:
|
git:
|
||||||
repo: "{{item.repo}}"
|
repo: "{{item.repo}}"
|
||||||
|
|
Loading…
Reference in New Issue