<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">That is already done by the mkdir imported from charmhelpers.core.host.<div class=""><br class=""></div><div class="">— Beppe</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 07 nov 2017, at 13:06, John Meinel <<a href="mailto:john@arbash-meinel.com" class="">john@arbash-meinel.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">It seems like you would tend to use:<div class="">import os</div><div class=""><br class=""></div><div class="">os.makedirs(os.path.dirname(config_file))</div><div class=""><br class=""></div><div class="">Which doesn't treat a directory that already exists as a failure.</div><div class="">However, I'm guessing that there is some other expectation that the directory should be created at some other time.</div><div class=""><br class=""></div><div class="">John</div><div class="">=:-></div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Nov 7, 2017 at 3:57 PM, Giuseppe Attardi <span dir="ltr" class=""><<a href="mailto:giuseppe.attardi@garr.it" target="_blank" class="">giuseppe.attardi@garr.it</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I run into a problem when adding a unit to keystone.<br class="">
<br class="">
The log shows this;<br class="">
<br class="">
2017-11-07 11:18:11 DEBUG leader-settings-changed   File "/var/lib/juju/agents/unit-<wbr class="">keystone-ba1-cl2-14/charm/<wbr class="">hooks/leader-settings-changed"<wbr class="">, line 675, in leader_settings_changed<br class="">
2017-11-07 11:18:11 DEBUG leader-settings-changed     update_all_identity_relation_<wbr class="">units()<br class="">
2017-11-07 11:18:11 DEBUG leader-settings-changed   File "/var/lib/juju/agents/unit-<wbr class="">keystone-ba1-cl2-14/charm/<wbr class="">hooks/leader-settings-changed"<wbr class="">, line 353, in update_all_identity_relation_<wbr class="">units<br class="">
2017-11-07 11:18:11 DEBUG leader-settings-changed     CONFIGS.write_all()<br class="">
2017-11-07 11:18:11 DEBUG leader-settings-changed   File "/var/lib/juju/agents/unit-<wbr class="">keystone-ba1-cl2-14/charm/<wbr class="">hooks/charmhelpers/contrib/<wbr class="">openstack/templating.py", line 285, in write_all<br class="">
2017-11-07 11:18:11 DEBUG leader-settings-changed     [self.write(k) for k in six.iterkeys(self.templates)]<br class="">
2017-11-07 11:18:11 DEBUG leader-settings-changed   File "/var/lib/juju/agents/unit-<wbr class="">keystone-ba1-cl2-14/charm/<wbr class="">hooks/charmhelpers/contrib/<wbr class="">openstack/templating.py", line 276, in write<br class="">
2017-11-07 11:18:11 DEBUG leader-settings-changed     with open(config_file, 'wb') as out:<br class="">
2017-11-07 11:18:11 DEBUG leader-settings-changed IOError: [Errno 2] No such file or directory: '/etc/keystone/keystone.conf'<br class="">
2017-11-07 11:18:11 ERROR juju.worker.uniter.operation runhook.go:107 hook "leader-settings-changed" failed: exit status 1<br class="">
<br class="">
and indeed the directory /etc/keystone is still missing.<br class="">
I am using Juju 2.2.4 and a variant of the keystone charm from stable/17.08.<br class="">
<br class="">
I solved the problem by adding:<br class="">
<br class="">
        from charmhelpers.core.host import (mkdir) # Attardi<br class="">
        mkdir(os.path.dirname(config_<wbr class="">file)) # Attardi<br class="">
<br class="">
in templating.py before line 276.<br class="">
Doing so should be no harm, but I wonder whether this is the right solution.<br class="">
<br class="">
— Beppe<br class="">
<span class="HOEnZb"><font color="#888888" class=""><br class="">
<br class="">
--<br class="">
Juju mailing list<br class="">
<a href="mailto:Juju@lists.ubuntu.com" class="">Juju@lists.ubuntu.com</a><br class="">
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/juju" rel="noreferrer" target="_blank" class="">https://lists.ubuntu.com/<wbr class="">mailman/listinfo/juju</a><br class="">
</font></span></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>