Puppet Class: azurelaagent::install_linux

Defined in:
manifests/install_linux.pp

Summary

Install agent on linux.

Overview

To override default value use yaml file and define variables like azurelaagent::install_linux::x64_download_path: 'https://github.com/Microsoft/OMS-Agent-for-Linux/releases/download/OMSAgent_v1.8.1.256/omsagent-1.8.1-256.universal.x64.sh'

Parameters:

  • ensure (String)

    'present' to install the agent, 'absent' to uninstall the agent

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

    Azure workspace ID (passed from init.pp)

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

    Azure shared key (passed from init.pp)

  • x64_download_path (String)

    URL of the 64 bit agent

  • x86_download_path (String)

    URL of the 32 bit agent

  • path_to_download (String)

    Where to download the installer

  • downloaded_script (String)

    Name of the installer script

  • use_proxy (Optional[Boolean]) (defaults to: false)

    True to use a proxy (passed from init.pp)

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

    Proxy URL like [protocol://][user:password@]proxyhost:port

See Also:



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
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
# File 'manifests/install_linux.pp', line 27

class azurelaagent::install_linux (
  String $ensure,

  String $x64_download_path,
  String $x86_download_path,
  String $path_to_download,
  String $downloaded_script,

  Optional[String] $azure_id = undef,
  Optional[String] $azure_shared = undef,

  Optional[Boolean] $use_proxy = false,
  Optional[String] $proxy = undef,

  # Optional[Array] $packages_to_install = ['glibc','openssl','curl','python-ctypes','pam'],  
){
  # Look for the right version of the installation script
  if ($::architecture == 'amd64' or $::architecture == 'x86_64') {
    # 64 bit
    $file_to_download = $x64_download_path
  } elsif ($::architecture == 'x86' or $::architecture == 'i386') {
    # 32 bit
    $file_to_download = $x86_download_path
  } else {
    fail("The fact 'architecture' is set to ${::architecture} which is not supported.")
  }

  if ($use_proxy and $proxy != '' and $proxy != undef) {
    $download_command = "wget -e use_proxy=yes -e http_proxy=${proxy} ${file_to_download} -O ${path_to_download}/${downloaded_script}"
  } else {
    $download_command = "wget ${file_to_download} -O ${path_to_download}/${downloaded_script}"
  }

  # Installation script download
  exec { 'OMSAgent install script download':
    path    => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/puppetlabs/bin',
    command => $download_command,
    unless  => "test -f ${path_to_download}/${downloaded_script}",
  }

  file { "${path_to_download}/${downloaded_script}":
    mode => '0744',
  }

  if ($ensure == 'present') {
    # Install Agent

    # package {$packages_to_install:
    #   ensure => present,
    # }

    if ($use_proxy and $proxy != '' and $proxy != undef) {
      $install_command = "${path_to_download}/${downloaded_script} --upgrade -p ${proxy} -w ${azure_id} -s ${azure_shared}"
    } else {
      $install_command = "${path_to_download}/${downloaded_script} --upgrade -w ${azure_id} -s ${azure_shared}"
    }

    # Agent installation
    exec { 'OMSAgent installation':
      path    => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/puppetlabs/bin',
      command => $install_command,
      unless  => 'test -f /opt/microsoft/omsagent/bin/omsadmin.sh',
      require => Exec['OMSAgent install script download'],
    }

  } elsif ($ensure == 'absent') {
    # Uninstall Agent
    exec { 'OMSAgent uninstallation':
      path    => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/puppetlabs/bin',
      command => "${path_to_download}/${downloaded_script} --purge",
      onlyif  => 'test -f /opt/microsoft/omsagent/bin/omsadmin.sh',
      require => Exec['OMSAgent install script download'],
    }

  } else {
    fail('The ensure param must be present or absent')
  }

}