Puppet Class: etcd::auth

Defined in:
manifests/auth.pp

Summary

This class manages auth-related stuff

Overview



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'manifests/auth.pp', line 7

class etcd::auth {
  assert_private()

  Etcd_role {
    before => Exec['etcd::auth'],
  }

  Etcd_role_permission {
    before => Exec['etcd::auth'],
  }

  Etcd_user {
    before => Exec['etcd::auth'],
  }

  create_resources('etcd_role', $etcd::roles)
  create_resources('etcd_role_permission', $etcd::role_permissions)
  create_resources('etcd_user', $etcd::users)

  if $etcd::purge_roles {
    resources { 'etcd_role':
      purge => true,
    }
  }

  if $etcd::purge_role_permissions {
    resources { 'etcd_role_permission':
      purge => true,
    }
  }

  if $etcd::purge_users {
    resources { 'etcd_user':
      purge => true,
    }
  }

  $env_list = $etcd::etcdctl_env.map |$key, $value| { "${key}='${value}'" }
  $env = join($env_list, ' ')
  $etcdctl = "env ${env} ETCDCTL_WRITE_OUT='simple' etcdctl"
  $auth_disabled = "${etcdctl} auth status | grep 'Authentication Status: false'"

  if $etcd::auth {
    exec { 'etcd::auth':
      path    => $facts['path'],
      command => "${etcdctl} auth enable",
      onlyif  => $auth_disabled,
    }
  } else {
    exec { 'etcd::auth':
      path    => $facts['path'],
      command => "${etcdctl} auth disable",
      unless  => $auth_disabled,
    }
  }
}