@when_not('leadership.is_leader')
def setup_non_leader_authentication():
    service_key = '/root/cdk/serviceaccount.key'
    basic_auth = '/root/cdk/basic_auth.csv'
    known_tokens = '/root/cdk/known_tokens.csv'
    keys = [service_key, basic_auth, known_tokens]
    if (not get_keys_from_leader(keys, overwrite_local=True)):
        return
    if ((not any_file_changed(keys)) and is_state('authentication.setup')):
        return
    hookenv.status_set('maintenance', 'Rendering authentication templates.')
    api_opts = FlagManager('kube-apiserver')
    api_opts.add('basic-auth-file', basic_auth)
    api_opts.add('token-auth-file', known_tokens)
    api_opts.add('service-account-key-file', service_key)
    controller_opts = FlagManager('kube-controller-manager')
    controller_opts.add('service-account-private-key-file', service_key)
    remove_state('kubernetes-master.components.started')
    set_state('authentication.setup')
@when_not('leadership.is_leader')
def setup_non_leader_authentication():
    service_key = '/root/cdk/serviceaccount.key'
    basic_auth = '/root/cdk/basic_auth.csv'
    known_tokens = '/root/cdk/known_tokens.csv'
    keys = [service_key, basic_auth, known_tokens]
    if (not get_keys_from_leader(keys, overwrite_local=True)):
        return
    if ((not any_file_changed(keys)) and is_state('authentication.setup')):
        return
    hookenv.status_set('maintenance', 'Rendering authentication templates.')
    api_opts = FlagManager('kube-apiserver')
    api_opts.add('basic-auth-file', basic_auth)
    api_opts.add('token-auth-file', known_tokens)
    api_opts.add('service-account-key-file', service_key)
    controller_opts = FlagManager('kube-controller-manager')
    controller_opts.add('service-account-private-key-file', service_key)
    remove_state('kubernetes-master.components.started')
    set_state('authentication.setup')