failover fails if master is down and slave is not 'healthiest'
I've had a sittuation where I deliberately shut down the only slave and then the master. I then 'lost' the master and restarted the slave, but it refused to become master because it was:
'Following a different leader because i am not the healthiest node'. 
Except that there was no other node (the former master was lost, no other slave exists.) I am not entirely sure why it considered itself unhealthy, but manually promoting with pg_ctl promote worked and got the cluster back up and running. 
I'm afraid I don't have enough details to reproduce the scenario. If I try to replicate what I did again it just works fine. 

diff --git a/patroni/postgresql.py b/patroni/postgresql.py
index a5b1e16..909a120 100644
--- a/patroni/postgresql.py
+++ b/patroni/postgresql.py
@@ -469,17 +469,15 @@ class Postgresql(object):
                     return pattern and (pattern in line)
         return not pattern
 
-    def write_recovery_conf(self, leader, bootstrap=False):
+    def write_recovery_conf(self, leader):
         with open(self.recovery_conf, 'w') as f:
-            f.write("""standby_mode = 'on'
-recovery_target_timeline = 'latest'
-""")
+            f.write("standby_mode = 'on'\\nrecovery_target_timeline = 'latest'\\n")
             if leader and leader.conn_url:
-                f.write("""primary_conninfo = '{0}'\\n""".format(self.primary_conninfo(leader.conn_url)))
+                f.write("primary_conninfo = '{0}'\\n".format(self.primary_conninfo(leader.conn_url)))
                 if self.use_slots:
-                    f.write("""primary_slot_name = '{0}'\\n""".format(self.name))
-            if (leader and leader.conn_url) or bootstrap:
-                for name, value in self.config.get('recovery_conf', {}).items():
+                    f.write("primary_slot_name = '{0}'\\n".format(self.name))
+            for name, value in self.config.get('recovery_conf', {}).items():
+                if name not in ('standby_mode', 'recovery_target_timeline', 'primary_conninfo', 'primary_slot_name'):
                     f.write("{0} = '{1}'\\n".format(name, value))
 
     def rewind(self, leader):
@@ -729,7 +727,7 @@ $$""".format(name, options), name, password, password)
         else:
             if self.sync_replica(clone_member):
                 self.restore_configuration_files()
-                self.write_recovery_conf(clone_member, True)
+                self.write_recovery_conf(clone_member)
                 ret = self.start()
         return ret
 
['patroni/postgresql.py']