Shell block in ansible playbook. How ?

10 views
Skip to first unread message

onenessboy

unread,
Aug 9, 2018, 11:47:53 AM8/9/18
to Ansible Project
Hi all,

I have some sample script

#!/bin/bash
#ip=$2
tar_file=$1
bkp_name="bkp-$$"

if [ -z "${tar_file}" ]; then
    echo "Usage import.sh [tar file]"
    exit 1
fi
for keyspace
do
keyspace=$(basename "${tar_file}" ".tar.gz")

mkdir -p "${bkp_name}"

tar -xvzf "${tar_file}" -C "${bkp_name}"

echo "Drop keyspace ${keyspace}"
cqlsh localhost -e "drop keyspace \"${keyspace}\";"

echo "Create empty keyspace: ${keyspace}"
cat "${bkp_name}/${keyspace}.sql" | cqlsh localhost

for dir in "${bkp_name}/${keyspace}/"*; do
    sstableloader -d  localhost${dir}"
done
done

How can I include entire script above in ansible-playbook ...?

Kai Stian Olstad

unread,
Aug 9, 2018, 11:59:04 AM8/9/18
to ansible...@googlegroups.com
On 09.08.2018 17:47, onenessboy wrote:
> How can I include entire script above in ansible-playbook ...?

Use the script module.

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages