Browse Source

devstack: Make some actions less error prone

The patch checks some resources existence before an attempt to
create them. If such resources already exist, originals are
kept.

Change-Id: Ib68ab9949520d84f2200e9b1ef5dca5ce3a9f879
Jakub Libosvar 5 months ago
parent
commit
82bee8feca
1 changed files with 4 additions and 3 deletions
  1. 4
    3
      devstack/plugin.sh

+ 4
- 3
devstack/plugin.sh View File

@@ -13,13 +13,13 @@ NET_ANSIBLE_OVS_PORT=${NET_ANSIBLE_OVS_PORT:-net-ans-p0}
13 13
 SSH_KEY_FILE=~/.ssh/id_rsa
14 14
 
15 15
 function ansible_workarounds {
16
-    sudo pip uninstall ansible -y
16
+    sudo pip uninstall ansible -y || :
17 17
 
18 18
     # This is a workaround for issue https://github.com/ansible/ansible/issues/42108
19 19
     # fix is currenlty merged in devel branch, requested as a backport to 2.6
20 20
     # until we have a build with the fix, we compile upstream devel branch
21 21
     pushd /opt/stack
22
-    git clone https://github.com/ansible/ansible.git
22
+    [ -d ansible ] || git clone https://github.com/ansible/ansible.git
23 23
     cd ansible
24 24
     git checkout stable-2.6
25 25
     python setup.py build
@@ -84,7 +84,8 @@ function test-config {
84 84
     sudo ovs-vsctl set Port $NET_ANSIBLE_OVS_PORT tag=[]
85 85
 
86 86
     # Allow ansible on localhost
87
-    ssh-keygen -q -t rsa -P '' -f $SSH_KEY_FILE
87
+    [ -f $SSH_KEY_FILE ] || ssh-keygen -q -t rsa -P '' -f $SSH_KEY_FILE
88
+    [ -f ${SSH_KEY_FILE}.pub ] || ssh-keygen -y -f $SSH_KEY_FILE > ${SSH_KEY_FILE}.pub
88 89
     cat ${SSH_KEY_FILE}.pub >> ~/.ssh/authorized_keys
89 90
     chmod 600 ~/.ssh/authorized_keys
90 91
 }

Loading…
Cancel
Save