Add Granafa Password
[osm/devops.git] / installers / charmed_install.sh
index c2a3a31..7bec50e 100755 (executable)
 # set -eux
 
 LXD_VERSION=4.0
-JUJU_VERSION=2.8
-JUJU_AGENT_VERSION=2.8.11
+JUJU_VERSION=2.9
+JUJU_AGENT_VERSION=2.9.22
 K8S_CLOUD_NAME="k8s-cloud"
 KUBECTL="microk8s.kubectl"
-MICROK8S_VERSION=1.20
+MICROK8S_VERSION=1.23
 OSMCLIENT_VERSION=10.0
 IMAGES_OVERLAY_FILE=~/.osm/images-overlay.yaml
 PATH=/snap/bin:${PATH}
 
 MODEL_NAME=osm
 
-OSM_BUNDLE=cs:osm-66
-OSM_HA_BUNDLE=cs:osm-ha-51
-TAG=10
+
+OSM_BUNDLE=ch:osm
+OSM_HA_BUNDLE=ch:osm-ha
+CHARMHUB_CHANNEL=10.0/edge
+unset TAG
 
 function check_arguments(){
     while [ $# -gt 0 ] ; do
@@ -54,16 +56,16 @@ function check_arguments(){
 
 function install_snaps(){
     if [ ! -v KUBECFG ]; then
+        KUBEGRP="microk8s"
         sudo snap install microk8s --classic --channel=${MICROK8S_VERSION}/stable
+        sudo usermod -a -G microk8s `whoami`
         sudo cat /var/snap/microk8s/current/args/kube-apiserver | grep advertise-address || (
                 echo "--advertise-address $DEFAULT_IP" | sudo tee -a /var/snap/microk8s/current/args/kube-apiserver
-                microk8s.stop
-                microk8s.start
+                sg ${KUBEGRP} -c microk8s.stop
+                sg ${KUBEGRP} -c microk8s.start
             )
-        sudo usermod -a -G microk8s `whoami`
         mkdir -p ~/.kube
         sudo chown -f -R `whoami` ~/.kube
-        KUBEGRP="microk8s"
         sg ${KUBEGRP} -c "microk8s status --wait-ready"
         KUBECONFIG=~/.osm/microk8s-config.yaml
         sg ${KUBEGRP} -c "microk8s config" | tee ${KUBECONFIG}
@@ -257,9 +259,9 @@ function deploy_charmed_osm(){
     fi
 
     if [ -v BUNDLE ]; then
-        juju deploy -m $MODEL_NAME $BUNDLE --overlay ~/.osm/vca-overlay.yaml $images_overlay $extra_overlay
+        juju deploy --trust --channel $CHARMHUB_CHANNEL -m $MODEL_NAME $BUNDLE --overlay ~/.osm/vca-overlay.yaml $images_overlay $extra_overlay
     else
-        juju deploy -m $MODEL_NAME $OSM_BUNDLE --overlay ~/.osm/vca-overlay.yaml $images_overlay $extra_overlay
+        juju deploy --trust --channel $CHARMHUB_CHANNEL -m $MODEL_NAME $OSM_BUNDLE --overlay ~/.osm/vca-overlay.yaml $images_overlay $extra_overlay
     fi
 
     if [ ! -v KUBECFG ]; then
@@ -279,6 +281,9 @@ function deploy_charmed_osm(){
     juju config -m $MODEL_NAME prometheus site_url=https://prometheus.${API_SERVER}.nip.io
 
     echo "Waiting for deployment to finish..."
+    grafana_leader=`juju status -m $MODEL_NAME grafana | grep "*" | cut -d "*" -f 1`
+    grafana_admin_password=`juju run -m $MODEL_NAME --unit $grafana_leader "echo \\$GF_SECURITY_ADMIN_PASSWORD"`
+    juju config -m $MODEL_NAME mon grafana_password=$grafana_admin_password
     check_osm_deployed
     echo "OSM with charms deployed"
 }
@@ -351,7 +356,7 @@ EOF
 function generate_images_overlay(){
     echo "applications:" > /tmp/images-overlay.yaml
 
-    charms_with_resources="nbi lcm mon pol ng-ui ro pla keystone"
+    charms_with_resources="nbi lcm mon pol ng-ui ro pla"
     for charm in $charms_with_resources; do
         cat << EOF > /tmp/${charm}_registry.yaml
 registrypath: ${REGISTRY_URL}opensourcemano/${charm}:$TAG
@@ -366,6 +371,23 @@ EOF
     resources:
       image: /tmp/${charm}_registry.yaml
 
+EOF
+    done
+    ch_charms_with_resources="keystone"
+    for charm in $ch_charms_with_resources; do
+        cat << EOF > /tmp/${charm}_registry.yaml
+registrypath: ${REGISTRY_URL}opensourcemano/${charm}:$TAG
+EOF
+        if [ ! -z "$REGISTRY_USERNAME" ] ; then
+            echo username: $REGISTRY_USERNAME >> /tmp/${charm}_registry.yaml
+            echo password: $REGISTRY_PASSWORD >> /tmp/${charm}_registry.yaml
+        fi
+
+        cat << EOF >> /tmp/images-overlay.yaml
+  ${charm}:
+    resources:
+      ${charm}-image: /tmp/${charm}_registry.yaml
+
 EOF
     done
 
@@ -460,7 +482,7 @@ if [ -v ONLY_VCA ]; then
     hostname=`cat /etc/hostname`
 
     echo "Use the following command to register the installed VCA to your OSM:"
-    echo -e "  osm vca-add --endpoints $vca_host:$vca_port \ \n         --user $vca_user \ \n         --secret $vca_secret \ \n         --cacert $vca_cacert \ \n         --lxd-cloud lxd-cloud \ \n         --lxd-credentials lxd-cloud \ \n         --k8s-cloud microk8s \ \n         --k8s-credentials microk8s\ \n         $hostname-vca"
+    echo -e "  osm vca-add --endpoints $vca_host:$vca_port \\\n         --user $vca_user \\\n         --secret $vca_secret \\\n         --cacert $vca_cacert \\\n         --lxd-cloud lxd-cloud \\\n         --lxd-credentials lxd-cloud \\\n         --k8s-cloud microk8s \\\n         --k8s-credentials microk8s\\\n         $hostname-vca"
 else
     deploy_charmed_osm
     install_osmclient