diff --git a/ambari-agent/Dockerfile b/ambari-agent/Dockerfile index 92ceb0c..ba2a7de 100644 --- a/ambari-agent/Dockerfile +++ b/ambari-agent/Dockerfile @@ -5,7 +5,6 @@ MAINTAINER Hortonworks ADD ambari.repo /etc/yum.repos.d/ RUN yum install -y ambari-agent && yum clean all -#RUN find /etc/rc.d/rc* -name "*ambari-agent" | xargs rm -v # add a custom folder to the hadoop classpath RUN mkdir -p /usr/lib/hadoop/lib @@ -23,9 +22,6 @@ RUN sed -i "s/\"ifconfig\"/\"ifconfig eth0\"/" /usr/lib/python2.6/site-packages/ ADD dash-azure-storage-2.2.0.jar /usr/lib/hadoop/lib/ ADD gcs-connector-latest-hadoop2.jar /usr/lib/hadoop/lib/ -ADD init/init-agent.sh /opt/ambari-agent/init-agent.sh -RUN chmod u+x /opt/ambari-agent/init-agent.sh - ADD init/ambari-agent.service /etc/systemd/system/ambari-agent.service RUN systemctl enable ambari-agent diff --git a/ambari-agent/docker_shared/etc/resolv.conf b/ambari-agent/docker_shared/etc/resolv.conf new file mode 100644 index 0000000..a8e7a07 --- /dev/null +++ b/ambari-agent/docker_shared/etc/resolv.conf @@ -0,0 +1,2 @@ +nameserver 172.17.0.2 +search service.consul node.dc1.consul diff --git a/ambari-agent/init/init-agent.sh b/ambari-agent/docker_shared/init-agent.sh similarity index 56% rename from ambari-agent/init/init-agent.sh rename to ambari-agent/docker_shared/init-agent.sh index 055de17..78a65f8 100755 --- a/ambari-agent/init/init-agent.sh +++ b/ambari-agent/docker_shared/init-agent.sh @@ -10,29 +10,6 @@ debug() { [[ "DEBUG" ]] && echo "[DEBUG] $@" 1>&2 } -get_nameserver_addr() { - if [[ "$NAMESERVER_ADDR" ]]; then - echo $NAMESERVER_ADDR - else - if ip addr show docker0 &> /dev/null; then - ip addr show docker0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1 - else - ip ro | grep default | cut -d" " -f 3 - fi - fi -} - -# --dns isn't available for: docker run --net=host -# sed -i /etc/resolf.conf fails: -# sed: cannot rename /etc/sedU9oCRy: Device or resource busy -# here comes the tempfile workaround ... -local_nameserver() { - cat>/etc/resolv.conf<$WORK_DIR/ambari_server_shared/etc/resolv.conf<$WORK_DIR/ambari_agent_shared/etc/resolv.conf< "} @@ -174,18 +280,18 @@ amb-start-node() { MORE_OPTIONS="$@" fi - run-command docker run $MORE_OPTIONS $DOCKER_OPTS --privileged --name ${NODE_PREFIX}$NUMBER -h ${NODE_PREFIX}${NUMBER}.service.consul $AMBARI_AGENT_IMAGE \ - systemd.setenv=NAMESERVER_ADDR=$(get-consul-ip) + cd ambari-agent && run-command docker run -v $AMBARI_AGENT_SHARED:/docker_shared $MORE_OPTIONS $DOCKER_OPTS --privileged --name ${NODE_PREFIX}$NUMBER -h ${NODE_PREFIX}${NUMBER}.service.consul $AMBARI_AGENT_IMAGE && cd .. _consul-register-service ${NODE_PREFIX}${NUMBER} $(get-host-ip ${NODE_PREFIX}$NUMBER) } _consul-register-service() { - curl -X PUT -d "{ - \"Node\": \"$1\", - \"Address\": \"$2\", - \"Service\": { - \"Service\": \"$1\" - } - }" http://$(get-consul-ip):8500/v1/catalog/register + echo "Dummy Registration" + # curl -X PUT -d "{ + # \"Node\": \"$1\", + # \"Address\": \"$2\", + # \"Service\": { + # \"Service\": \"$1\" + # } + #}" $(get-consul-base-url)/v1/catalog/register } diff --git a/ambari-server/Dockerfile b/ambari-server/Dockerfile index bf8c6d9..b3bfaee 100644 --- a/ambari-server/Dockerfile +++ b/ambari-server/Dockerfile @@ -16,9 +16,6 @@ ADD shell/ambari-shell.sh /tmp/ ENV PLUGIN_PATH /plugins WORKDIR /tmp -ADD init/init-server.sh /opt/ambari-server/init-server.sh -RUN chmod u+x /opt/ambari-server/init-server.sh - # add mysql and psql connectors to ambari-server so it can be downloaded by services (e.g.: Ranger) ADD http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.39.tar.gz /var/lib/ambari-server/resources/mysql-jdbc-driver.jar ADD https://jdbc.postgresql.org/download/postgresql-9.4.1208.jre7.jar /var/lib/ambari-server/resources/postgres-jdbc-driver.jar diff --git a/ambari-server/docker_shared/etc/resolv.conf b/ambari-server/docker_shared/etc/resolv.conf new file mode 100644 index 0000000..a8e7a07 --- /dev/null +++ b/ambari-server/docker_shared/etc/resolv.conf @@ -0,0 +1,2 @@ +nameserver 172.17.0.2 +search service.consul node.dc1.consul diff --git a/ambari-server/init/init-server.sh b/ambari-server/docker_shared/init-server.sh similarity index 82% rename from ambari-server/init/init-server.sh rename to ambari-server/docker_shared/init-server.sh index 8626ae1..71fc699 100755 --- a/ambari-server/init/init-server.sh +++ b/ambari-server/docker_shared/init-server.sh @@ -9,29 +9,6 @@ debug() { [[ "DEBUG" ]] && echo "[DEBUG] $@" 1>&2 } -get_nameserver_addr() { - if [[ "$NAMESERVER_ADDR" ]]; then - echo $NAMESERVER_ADDR - else - if ip addr show docker0 &> /dev/null; then - ip addr show docker0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1 - else - ip ro | grep default | cut -d" " -f 3 - fi - fi -} - -# --dns isn't available for: docker run --net=host -# sed -i /etc/resolf.conf fails: -# sed: cannot rename /etc/sedU9oCRy: Device or resource busy -# here comes the tempfile workaround ... -local_nameserver() { - cat>/etc/resolv.conf< /var/kerberos/krb5kdc/kadm5.acl +} + +fix_hostname() { + sed -i "/^hosts:/ s/ *files dns/ dns files/" /etc/nsswitch.conf +} + +create_db() { + /usr/sbin/kdb5_util -P $KERB_MASTER_KEY -r $REALM create -s +} + +start_kdc() { + mkdir -p /var/log/kerberos + + chkconfig krb5kdc on + chkconfig kadmin on + + /sbin/service krb5kdc start #/etc/rc.d/init.d/krb5kdc start + /sbin/service kadmin start #/etc/rc.d/init.d/kadmin start +} + +restart_kdc() { + /etc/rc.d/init.d/krb5kdc restart + /etc/rc.d/init.d/kadmin restart +} + +create_admin_user() { + kadmin.local -q "addprinc -pw $KERB_ADMIN_PASS $KERB_ADMIN_USER/admin" + echo "*/admin@$REALM *" > /var/kerberos/krb5kdc/kadm5.acl +} + +main() { + ln -s /docker_shared/etc/resolv.conf /tmp/resolv.conf + cp /tmp/resolv.conf /etc/resolv.conf + + mkdir -p /var/log/kerberos + + if [ ! -f /var/kerberos/kerberos_initialized ]; then + create_config + create_db + create_admin_user + start_kdc + + touch /var/kerberos/kerberos_initialized + fi + + tail -f /dev/null + #fix_hostname +} + +[[ "$0" == "$BASH_SOURCE" ]] && main "$@" diff --git a/docker-kerberos/docker_shared/krb5.conf b/docker-kerberos/docker_shared/krb5.conf new file mode 100644 index 0000000..f3bcd7f --- /dev/null +++ b/docker-kerberos/docker_shared/krb5.conf @@ -0,0 +1,22 @@ +[logging] + default = FILE:/var/log/kerberos/krb5libs.log + kdc = FILE:/var/log/kerberos/krb5kdc.log + admin_server = FILE:/var/log/kerberos/kadmind.log + +[libdefaults] + default_realm = SERVICE.CONSUL + dns_lookup_realm = false + dns_lookup_kdc = false + ticket_lifetime = 24h + renew_lifetime = 7d + forwardable = true + +[realms] + SERVICE.CONSUL = { + kdc = kerberos.service.consul + admin_server = kerberos.service.consul + } + +[domain_realm] + .service.consul = SERVICE.CONSUL + service.consul = SERVICE.CONSUL diff --git a/docker_shared/etc/krb5.conf b/docker_shared/etc/krb5.conf new file mode 100644 index 0000000..ef3be51 --- /dev/null +++ b/docker_shared/etc/krb5.conf @@ -0,0 +1,22 @@ +[logging] + default = FILE:/var/log/kerberos/krb5libs.log + kdc = FILE:/var/log/kerberos/krb5kdc.log + admin_server = FILE:/var/log/kerberos/kadmind.log + +[libdefaults] + default_realm = DSE.GROUP.ON + dns_lookup_realm = false + dns_lookup_kdc = false + ticket_lifetime = 24h + renew_lifetime = 7d + forwardable = true + +[realms] + DSE.GROUP.ON = { + kdc = kerberos.service.consul + admin_server = kerberos.service.consul + } + +[domain_realm] + .service.consul = DSE.GROUP.ON + service.consul = DSE.GROUP.ON diff --git a/docker_shared/etc/resolv.conf b/docker_shared/etc/resolv.conf new file mode 100644 index 0000000..a8e7a07 --- /dev/null +++ b/docker_shared/etc/resolv.conf @@ -0,0 +1,2 @@ +nameserver 172.17.0.2 +search service.consul node.dc1.consul