Puppet Class: oxidized

Defined in:
manifests/init.pp

Summary

Manage Oxidized

Overview

Examples:

include oxidized

Parameters:

  • manage_repo (Boolean) (defaults to: true)

    Sets if repos needed for oxidize are managed.

  • ruby_dependencies (Array) (defaults to: [])

    Ruby dependencies

  • install_dependencies (Array) (defaults to: [])

    Additional install dependencies

  • with_web (Boolean) (defaults to: false)

    Sets if the oxidized web should be installed and configured

  • package_ensure (String) (defaults to: 'installed')

    Ensure value for main oxidized package

  • script_package_ensure (String) (defaults to: 'installed')

    Ensure value for oxidized-script package

  • web_package_ensure (Optional[String]) (defaults to: undef)

    Ensure value for oxidized web package Defaults to installed when with_web is true

  • user (String) (defaults to: 'oxidized')

    Oxidize user

  • user_group (String) (defaults to: 'oxidized')

    Oxidize user's group

  • user_uid (Optional[Integer]) (defaults to: undef)

    Oxidize user's UID

  • user_group_gid (Optional[Integer]) (defaults to: undef)

    Oxidize user's group GID

  • user_home (Stdlib::Absolutepath) (defaults to: '/home/oxidized')

    Oxidize user's home directory path

  • user_home_mode (Stdlib::FileMode) (defaults to: '0700')

    The permissions of oxidized user's home directory

  • config (Hash) (defaults to: {})

    Oxidize config hash

  • config_mode (Stdlib::FileMode) (defaults to: '0600')

    Oxidized config file permission mode

  • source_type (Enum['csv']) (defaults to: 'csv')

    Sets type of source to be used

  • devices (Array[Hash]) (defaults to: [])

    Information about devices. Only used when source_type is csv

  • devices_map (Hash[String, Integer]) (defaults to: {'name' => 0, 'model' => 1})

    Map of CSV fields for devices Only used when source_type is csv

  • devices_vars_map (Optional[Hash[String, Integer]]) (defaults to: undef)

    Set vars_map for device CSV configuration Only used when source_type is csv

  • with_service (Boolean) (defaults to: false)

    Sets if the oxidized service should be installed and running

  • service_start (String) (defaults to: '/usr/local/bin/oxidized')

    The command to use to start oxidized service

  • show_diff (Boolean) (defaults to: true)

    Boolean that sets show_diff property for files

  • log (Optional[String]) (defaults to: undef)

    Path to oxidized log file

  • log_mode (Stdlib::FileMode) (defaults to: '0644')

    The permissions of oxidized log file

  • models (Hash) (defaults to: {})

    Hash of models passed to oxidized::model



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'manifests/init.pp', line 60

class oxidized (
  Boolean $manage_repo = true,
  Array $ruby_dependencies = [],
  Array $install_dependencies = [],
  Boolean $with_web = false,
  String $package_ensure = 'installed',
  String $script_package_ensure = 'installed',
  Optional[String] $web_package_ensure = undef,
  String $user = 'oxidized',
  String $user_group = 'oxidized',
  Optional[Integer] $user_uid = undef,
  Optional[Integer] $user_group_gid = undef,
  Stdlib::Absolutepath $user_home = '/home/oxidized',
  Stdlib::FileMode $user_home_mode = '0700',
  Hash $config = {},
  Stdlib::FileMode $config_mode = '0600',
  Enum['csv'] $source_type = 'csv',
  Array[Hash] $devices = [],
  Hash[String, Integer] $devices_map = {'name' => 0, 'model' => 1},
  Optional[Hash[String, Integer]] $devices_vars_map = undef,
  Boolean $with_service = false,
  String $service_start = '/usr/local/bin/oxidized',
  Boolean $show_diff = true,
  Optional[String] $log = undef,
  Stdlib::FileMode $log_mode = '0644',
  Hash $models = {},
) {

  if $facts.dig('os', 'family') == 'RedHat' {
    if versioncmp($facts['os']['release']['major'], '8') >= 0 {
      $bootstrap_command = 'oxidized'
    } else {
      $bootstrap_command = 'scl enable rh-ruby27 -- oxidized'
    }
  } else {
    $bootstrap_command = 'oxidized'
  }

  if $source_type == 'csv' {
    $router_db = "${user_home}/.config/oxidized/router.db"
    $default_source_config = {
      'default' => 'csv',
      'csv' => delete_undef_values({
        'file'  => $router_db,
        'delimiter' => ':',
        'map' => $devices_map,
        'vars_map' => $devices_vars_map,
      })
    }
  } else {
    $default_source_config = {
      'default' => 'file',
    }
  }

  if 'output' in $config {
    $output_config = $config['output']
  } else {
    $output_config = { 'file' => { 'directory' => "${user_home}/.config/oxidized/configs" } }
  }

  if $devices_vars_map {
    $csv_map = $devices_map + $devices_vars_map
  } else {
    $csv_map = $devices_map
  }

  if $with_web {
    $_web_package_ensure = pick($web_package_ensure, 'installed')
    $rest_config = '127.0.0.1:8888'
  } else {
    $_web_package_ensure = 'absent'
    $rest_config = false
  }

  if $with_service {
    $service_notify = Service['oxidized']
    $service_file_ensure = 'present'
    $service_ensure = 'running'
    $service_enable = true
  } else {
    $service_notify = undef
    $service_file_ensure = 'absent'
    $service_ensure = 'stopped'
    $service_enable = false
  }

  $default_config = delete_undef_values({
    'source' => $default_source_config,
    'output' => $output_config,
    'rest'   => $rest_config,
    'log'    => $log,
  })
  $_config = $default_config + $config

  contain 'oxidized::user'
  contain 'oxidized::install'
  contain 'oxidized::config'
  contain 'oxidized::service'

  Class['oxidized::user']
  -> Class['oxidized::install']
  -> Class['oxidized::config']
  -> Class['oxidized::service']

  if $manage_repo {
    contain 'oxidized::repo'
    Class['oxidized::repo'] -> Class['oxidized::install']
  }

  $models.each |$name, $model| {
    ::oxidized::model { $name: * => $model }
  }

}