# Shell block in ansible playbook. How ?

**URL:** <https://forum.ansible.com/t/shell-block-in-ansible-playbook-how/28301>\
**Category:** Ansible Project\
**Created:** [August 9, 2018, 3:47pm UTC](https://forum.ansible.com/t/shell-block-in-ansible-playbook-how/28301 "2018-08-09T15:47:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![onenessboy](https://avatars.discourse-cdn.com/v4/letter/o/90ced4/32.png) [@onenessboy](https://forum.ansible.com/u/onenessboy)\
**Post date:** [August 9, 2018, 3:47pm UTC](https://forum.ansible.com/t/shell-block-in-ansible-playbook-how/28301/1 "2018-08-09T15:47:53Z")

</div>

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 …?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [August 9, 2018, 3:58pm UTC](https://forum.ansible.com/t/shell-block-in-ansible-playbook-how/28301/2 "2018-08-09T15:58:52Z")

</div>

Use the script module.
