<div dir="ltr">It seems like you would tend to use:<div>import os</div><div><br></div><div>os.makedirs(os.path.dirname(config_file))</div><div><br></div><div>Which doesn't treat a directory that already exists as a failure.</div><div>However, I'm guessing that there is some other expectation that the directory should be created at some other time.</div><div><br></div><div>John</div><div>=:-></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 7, 2017 at 3:57 PM, Giuseppe Attardi <span dir="ltr"><<a href="mailto:giuseppe.attardi@garr.it" target="_blank">giuseppe.attardi@garr.it</a>></span> wrote:<br><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>
<br>
The log shows this;<br>
<br>
2017-11-07 11:18:11 DEBUG leader-settings-changed   File "/var/lib/juju/agents/unit-<wbr>keystone-ba1-cl2-14/charm/<wbr>hooks/leader-settings-changed"<wbr>, line 675, in leader_settings_changed<br>
2017-11-07 11:18:11 DEBUG leader-settings-changed     update_all_identity_relation_<wbr>units()<br>
2017-11-07 11:18:11 DEBUG leader-settings-changed   File "/var/lib/juju/agents/unit-<wbr>keystone-ba1-cl2-14/charm/<wbr>hooks/leader-settings-changed"<wbr>, line 353, in update_all_identity_relation_<wbr>units<br>
2017-11-07 11:18:11 DEBUG leader-settings-changed     CONFIGS.write_all()<br>
2017-11-07 11:18:11 DEBUG leader-settings-changed   File "/var/lib/juju/agents/unit-<wbr>keystone-ba1-cl2-14/charm/<wbr>hooks/charmhelpers/contrib/<wbr>openstack/templating.py", line 285, in write_all<br>
2017-11-07 11:18:11 DEBUG leader-settings-changed     [self.write(k) for k in six.iterkeys(self.templates)]<br>
2017-11-07 11:18:11 DEBUG leader-settings-changed   File "/var/lib/juju/agents/unit-<wbr>keystone-ba1-cl2-14/charm/<wbr>hooks/charmhelpers/contrib/<wbr>openstack/templating.py", line 276, in write<br>
2017-11-07 11:18:11 DEBUG leader-settings-changed     with open(config_file, 'wb') as out:<br>
2017-11-07 11:18:11 DEBUG leader-settings-changed IOError: [Errno 2] No such file or directory: '/etc/keystone/keystone.conf'<br>
2017-11-07 11:18:11 ERROR juju.worker.uniter.operation runhook.go:107 hook "leader-settings-changed" failed: exit status 1<br>
<br>
and indeed the directory /etc/keystone is still missing.<br>
I am using Juju 2.2.4 and a variant of the keystone charm from stable/17.08.<br>
<br>
I solved the problem by adding:<br>
<br>
        from charmhelpers.core.host import (mkdir) # Attardi<br>
        mkdir(os.path.dirname(config_<wbr>file)) # Attardi<br>
<br>
in templating.py before line 276.<br>
Doing so should be no harm, but I wonder whether this is the right solution.<br>
<br>
— Beppe<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Juju mailing list<br>
<a href="mailto:Juju@lists.ubuntu.com">Juju@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/juju" rel="noreferrer" target="_blank">https://lists.ubuntu.com/<wbr>mailman/listinfo/juju</a><br>
</font></span></blockquote></div><br></div>