Update install_osm.sh to solve the issue with no valid OpenPGP data found
[osm/devops.git] / installers / charmed_install.sh
index 577fe82..52f07f3 100755 (executable)
 
 LXD_VERSION=4.0
 JUJU_VERSION=2.9
-JUJU_AGENT_VERSION=2.9.17
+JUJU_AGENT_VERSION=2.9.22
 K8S_CLOUD_NAME="k8s-cloud"
 KUBECTL="microk8s.kubectl"
-MICROK8S_VERSION=1.20
-OSMCLIENT_VERSION=10.0
+MICROK8S_VERSION=1.23
+OSMCLIENT_VERSION=11.0
 IMAGES_OVERLAY_FILE=~/.osm/images-overlay.yaml
 PATH=/snap/bin:${PATH}
 
 MODEL_NAME=osm
 
-# Latest bundles using old mongodb-k8s
-# OSM_BUNDLE=cs:osm-68
-# OSM_HA_BUNDLE=cs:osm-ha-54
-# The charm store does not support referencing charms from CharmHub,
-# therefore we will point to the local bundles until we migrate all
-# charms to CharmHub.
-OSM_BUNDLE=/usr/share/osm-devops/installers/charm/bundles/osm/bundle.yaml
-OSM_HA_BUNDLE=/usr/share/osm-devops/installers/charm/bundles/osm-ha/bundle.yaml
-TAG=testing-daily
+OSM_BUNDLE=ch:osm
+OSM_HA_BUNDLE=ch:osm-ha
+CHARMHUB_CHANNEL=11.0/edge
+unset TAG
 
 function check_arguments(){
     while [ $# -gt 0 ] ; do
@@ -60,16 +55,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}
@@ -263,9 +258,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
@@ -286,6 +281,10 @@ function deploy_charmed_osm(){
 
     echo "Waiting for deployment to finish..."
     check_osm_deployed
+    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"
 }
 
@@ -296,7 +295,7 @@ function check_osm_deployed() {
     previous_count=0
     while true
     do
-        service_count=$(juju status -m $MODEL_NAME | grep kubernetes | grep active | wc -l)
+        service_count=$(juju status --format json -m $MODEL_NAME | jq '.applications[]."application-status".current' | grep active | wc -l)
         echo "$service_count / $total_service_count services active"
         if [ $service_count -eq $total_service_count ]; then
             break
@@ -357,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
@@ -372,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