~julian-edwards/maas/stop-dhcp-bug-1059459

« back to all changes in this revision

Viewing changes to debian/maas.postinst

  • Committer: Tarmac
  • Author(s): Raphael Badin
  • Date: 2012-09-21 16:10:29 UTC
  • mfrom: (87.2.7 set-rabbitmq-creds)
  • Revision ID: ed@carob-20120921161029-tsm2w4nk25z03y9r
[r=andreserl][bug=1050492][author=rvb] Add method in debian/maas.postinst to create the RabbitMQ user used by workers and update BROKER_URL in /etc/maas/maas_local_settings.py.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
        fi
78
78
}
79
79
 
 
80
configure_maas_workers_rabbitmq_user() {
 
81
        local workers_user="maas_workers"
 
82
        local workers_pass="$(pwgen -s 20)"
 
83
        local workers_vhost="/maas_workers"
 
84
        local amqp_host="localhost"
 
85
        local amqp_port="5672"
 
86
        if [ -x /usr/sbin/rabbitmqctl ]; then
 
87
                if ! rabbitmqctl list_users | grep -qs "$workers_user"; then
 
88
                        rabbitmqctl add_user "$workers_user" "$workers_pass" || true
 
89
                        rabbitmqctl add_vhost "$workers_vhost" || true
 
90
                        rabbitmqctl set_permissions -p "$workers_vhost" "$workers_user" ".*" ".*" ".*" || true
 
91
                else
 
92
                        rabbitmqctl change_password "$workers_user" "$workers_pass" || true
 
93
                fi
 
94
        fi
 
95
 
 
96
        if grep -qs "^BROKER_URL\ \= '.*'$" /etc/maas/maas_local_celeryconfig.py; then
 
97
                local broker_url="amqp://$workers_user:$workers_pass@$amqp_host:$amqp_port/$workers_vhost"
 
98
                sed -i "s|^BROKER_URL\ \= '.*'$|BROKER_URL = '"$broker_url"'|" \
 
99
                       /etc/maas/maas_local_celeryconfig.py
 
100
        fi
 
101
}
 
102
 
80
103
configure_maas_database() {
81
104
        local dbc_dbpass="$1"
82
105
        if grep -qs "^\ \{1,\} 'PASSWORD': '[a-zA-Z0-9]\{0,\}',$" /etc/maas/maas_local_settings.py; then
182
205
        configure_maas_txlongpoll_rabbitmq_user
183
206
 
184
207
        #########################################################
 
208
        ########## Configure worker rabbitmq config ###########
 
209
        #########################################################
 
210
 
 
211
        # Handle celery/rabbitmq publishing
 
212
        configure_maas_workers_rabbitmq_user
 
213
 
 
214
        #########################################################
185
215
        ######## add maas.conf to tgt conf.d ####################
186
216
        #########################################################
187
217
        configure_maas_tgt