aboutsummaryrefslogtreecommitdiffstats
path: root/distribution/cassandra_job
diff options
context:
space:
mode:
Diffstat (limited to 'distribution/cassandra_job')
-rw-r--r--distribution/cassandra_job/Dockerfile9
-rw-r--r--distribution/cassandra_job/admin.cql17
-rw-r--r--distribution/cassandra_job/admin_pw.cql2
-rw-r--r--distribution/cassandra_job/runcql.sh31
-rw-r--r--distribution/cassandra_job/test.cql2
5 files changed, 61 insertions, 0 deletions
diff --git a/distribution/cassandra_job/Dockerfile b/distribution/cassandra_job/Dockerfile
new file mode 100644
index 00000000..528c3bf4
--- /dev/null
+++ b/distribution/cassandra_job/Dockerfile
@@ -0,0 +1,9 @@
+#registry.hub.docker.com/
+FROM library/cassandra:3.11
+ENV DEF_USER=cassandra
+ENV DEF_PASS=cassandra
+COPY runcql.sh /
+RUN mkdir -p cql/extra && \
+ chmod 755 runcql.sh && \
+ chown cassandra runcql.sh
+CMD ["/runcql.sh"]
diff --git a/distribution/cassandra_job/admin.cql b/distribution/cassandra_job/admin.cql
new file mode 100644
index 00000000..904a2bab
--- /dev/null
+++ b/distribution/cassandra_job/admin.cql
@@ -0,0 +1,17 @@
+CREATE KEYSPACE IF NOT EXISTS admin
+ WITH REPLICATION = {
+ 'class' : 'SimpleStrategy',
+ 'replication_factor': 1
+ }
+ AND DURABLE_WRITES = true;
+
+CREATE TABLE IF NOT EXISTS admin.keyspace_master (
+ uuid uuid,
+ keyspace_name text,
+ application_name text,
+ is_api boolean,
+ password text,
+ username text,
+ is_aaf boolean,
+ PRIMARY KEY (uuid)
+);
diff --git a/distribution/cassandra_job/admin_pw.cql b/distribution/cassandra_job/admin_pw.cql
new file mode 100644
index 00000000..bbad8d1d
--- /dev/null
+++ b/distribution/cassandra_job/admin_pw.cql
@@ -0,0 +1,2 @@
+CREATE ROLE IF NOT EXISTS <CASSUSER> WITH PASSWORD = '<CASSPASS>' AND SUPERUSER = True AND LOGIN = True;
+ALTER ROLE cassandra WITH PASSWORD = 'SomeLongRandomStringNoonewillthinkof';
diff --git a/distribution/cassandra_job/runcql.sh b/distribution/cassandra_job/runcql.sh
new file mode 100644
index 00000000..e1fb31fc
--- /dev/null
+++ b/distribution/cassandra_job/runcql.sh
@@ -0,0 +1,31 @@
+#! /bin/bash
+if [ $CASS_HOSTNAME ]; then
+ echo "#############################################"
+ echo "############## Let run cql's ################"
+ echo "#############################################"
+ echo "admin.cql file:"
+ cat /cql/admin.cql
+ echo "Running cqlsh -u $DEF_USER -p $DEF_PASS -f /cql/admin.cql ${CASS_HOSTNAME} ${PORT}"
+ sleep 1;
+ if cqlsh -u $DEF_USER -p $DEF_PASS -f /cql/admin.cql ${CASS_HOSTNAME} ${PORT}; then echo "success"; else echo "failure" && exit 1;fi
+ echo "admin_pw.cql file:"
+ cat /cql/admin_pw.cql
+ echo "Running cqlsh -u $DEF_USER -p $DEF_PASS -f /cql/admin_pw.cql ${CASS_HOSTNAME} ${PORT}"
+ sleep 1;
+ if cqlsh -u $DEF_USER -p $DEF_PASS -f /cql/admin_pw.cql ${CASS_HOSTNAME} ${PORT}; then echo "success"; else echo "failure" && exit 1;fi
+
+ for f in /cql/extra/*; do
+ case "$f" in
+ *.cql)
+ echo "$0: running $f" && cqlsh -u ${USERNAME} -p ${PASSWORD} -f "$f" ${CASS_HOSTNAME} ${PORT};
+ ;;
+ *)
+ echo "$0: ignoring $f"
+ ;;
+ esac
+ done
+else
+ echo "Missing CASS_HOSTNAME";
+ exit 1;
+fi
+
diff --git a/distribution/cassandra_job/test.cql b/distribution/cassandra_job/test.cql
new file mode 100644
index 00000000..196fea22
--- /dev/null
+++ b/distribution/cassandra_job/test.cql
@@ -0,0 +1,2 @@
+DESCRIBE keyspaces;
+