mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-30 17:15:11 +02:00
enhance ansible for non ssl connection
This commit is contained in:
parent
2e5cd7dc6b
commit
d021ed66cb
@ -40,7 +40,7 @@ sub new {
|
|||||||
|
|
||||||
if (!defined($options{noptions})) {
|
if (!defined($options{noptions})) {
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'host:s' => { name => 'host' },
|
'hostname:s' => { name => 'hostname' },
|
||||||
'username:s' => { name => 'username' },
|
'username:s' => { name => 'username' },
|
||||||
'password:s' => { name => 'password' },
|
'password:s' => { name => 'password' },
|
||||||
'timeout:s' => { name => 'timeout', default => 50 },
|
'timeout:s' => { name => 'timeout', default => 50 },
|
||||||
@ -48,6 +48,7 @@ sub new {
|
|||||||
'command:s' => { name => 'command', default => 'tower-cli' },
|
'command:s' => { name => 'command', default => 'tower-cli' },
|
||||||
'command-path:s' => { name => 'command_path' },
|
'command-path:s' => { name => 'command_path' },
|
||||||
'command-options:s' => { name => 'command_options', default => '' },
|
'command-options:s' => { name => 'command_options', default => '' },
|
||||||
|
'nossl' => { name => 'nossl' },
|
||||||
'proxyurl:s' => { name => 'proxyurl' }
|
'proxyurl:s' => { name => 'proxyurl' }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -74,9 +75,15 @@ sub check_options {
|
|||||||
$ENV{HTTPS_PROXY} = $self->{option_results}->{proxyurl};
|
$ENV{HTTPS_PROXY} = $self->{option_results}->{proxyurl};
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{host} = (defined($self->{option_results}->{host})) ? $self->{option_results}->{host} : undef;
|
$self->{hostname} = (defined($self->{option_results}->{hostname})) && $self->{option_results}->{hostname} ne '' ? $self->{option_results}->{hostname} : undef;
|
||||||
$self->{username} = (defined($self->{option_results}->{username})) ? $self->{option_results}->{username} : undef;
|
$self->{username} = (defined($self->{option_results}->{username})) && $self->{option_results}->{username} ne '' ? $self->{option_results}->{username} : undef;
|
||||||
$self->{password} = (defined($self->{option_results}->{password})) ? $self->{option_results}->{password} : undef;
|
$self->{password} = (defined($self->{option_results}->{password})) && $self->{option_results}->{password} ne '' ? $self->{option_results}->{password} : undef;
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{nossl})) {
|
||||||
|
$ENV{TOWER_VERIFY_SSL} = 'no';
|
||||||
|
$self->{hostname} = 'http://' . $self->{hostname} if (defined($self->{hostname}));
|
||||||
|
$ENV{HTTPS_PROXY} = $self->{option_results}->{proxyurl};
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -92,7 +99,8 @@ sub execute {
|
|||||||
sudo => $self->{option_results}->{sudo},
|
sudo => $self->{option_results}->{sudo},
|
||||||
command => $self->{option_results}->{command},
|
command => $self->{option_results}->{command},
|
||||||
command_path => $self->{option_results}->{command_path},
|
command_path => $self->{option_results}->{command_path},
|
||||||
command_options => $options{cmd_options});
|
command_options => $options{cmd_options}
|
||||||
|
);
|
||||||
|
|
||||||
my $raw_results;
|
my $raw_results;
|
||||||
|
|
||||||
@ -114,9 +122,9 @@ sub tower_list_hosts_set_cmd {
|
|||||||
return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||||
|
|
||||||
my $cmd_options = "host list --insecure --all-pages --format json";
|
my $cmd_options = "host list --insecure --all-pages --format json";
|
||||||
$cmd_options .= " --tower-host '$self->{host}'" if (defined($self->{host}) && $self->{host} ne '');
|
$cmd_options .= " --tower-host '$self->{hostname}'" if (defined($self->{hostname}));
|
||||||
$cmd_options .= " --tower-username '$self->{username}'" if (defined($self->{username}) && $self->{username} ne '');
|
$cmd_options .= " --tower-username '$self->{username}'" if (defined($self->{username}));
|
||||||
$cmd_options .= " --tower-password '$self->{password}'" if (defined($self->{password}) && $self->{password} ne '');
|
$cmd_options .= " --tower-password '$self->{password}'" if (defined($self->{password}));
|
||||||
$cmd_options .= " --group '$options{group}'" if (defined($options{group}) && $options{group} ne '');
|
$cmd_options .= " --group '$options{group}'" if (defined($options{group}) && $options{group} ne '');
|
||||||
$cmd_options .= " --inventory '$options{inventory}'" if (defined($options{inventory}) && $options{inventory} ne '');
|
$cmd_options .= " --inventory '$options{inventory}'" if (defined($options{inventory}) && $options{inventory} ne '');
|
||||||
|
|
||||||
@ -137,10 +145,10 @@ sub tower_list_inventories_set_cmd {
|
|||||||
|
|
||||||
return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||||
|
|
||||||
my $cmd_options = "inventory list --insecure --all-pages --format json";
|
my $cmd_options = 'inventory list --insecure --all-pages --format json';
|
||||||
$cmd_options .= " --tower-host '$self->{host}'" if (defined($self->{host}) && $self->{host} ne '');
|
$cmd_options .= " --tower-host '$self->{hostname}'" if (defined($self->{hostname}));
|
||||||
$cmd_options .= " --tower-username '$self->{username}'" if (defined($self->{username}) && $self->{username} ne '');
|
$cmd_options .= " --tower-username '$self->{username}'" if (defined($self->{username}));
|
||||||
$cmd_options .= " --tower-password '$self->{password}'" if (defined($self->{password}) && $self->{password} ne '');
|
$cmd_options .= " --tower-password '$self->{password}'" if (defined($self->{password}));
|
||||||
|
|
||||||
return $cmd_options;
|
return $cmd_options;
|
||||||
}
|
}
|
||||||
@ -160,9 +168,9 @@ sub tower_list_projects_set_cmd {
|
|||||||
return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||||
|
|
||||||
my $cmd_options = "project list --insecure --all-pages --format json";
|
my $cmd_options = "project list --insecure --all-pages --format json";
|
||||||
$cmd_options .= " --tower-host '$self->{host}'" if (defined($self->{host}) && $self->{host} ne '');
|
$cmd_options .= " --tower-host '$self->{hostname}'" if (defined($self->{hostname}));
|
||||||
$cmd_options .= " --tower-username '$self->{username}'" if (defined($self->{username}) && $self->{username} ne '');
|
$cmd_options .= " --tower-username '$self->{username}'" if (defined($self->{username}));
|
||||||
$cmd_options .= " --tower-password '$self->{password}'" if (defined($self->{password}) && $self->{password} ne '');
|
$cmd_options .= " --tower-password '$self->{password}'" if (defined($self->{password}));
|
||||||
|
|
||||||
return $cmd_options;
|
return $cmd_options;
|
||||||
}
|
}
|
||||||
@ -192,9 +200,9 @@ To install the Tower CLI : https://docs.ansible.com/ansible-tower/latest/html/to
|
|||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
=item B<--host>
|
=item B<--hostname>
|
||||||
|
|
||||||
Ansible Tower host (Default uses setting in 'tower config').
|
Ansible Tower hostname (Default uses setting in 'tower config').
|
||||||
|
|
||||||
=item B<--username>
|
=item B<--username>
|
||||||
|
|
||||||
@ -204,6 +212,10 @@ Ansible Tower username (Default uses setting in 'tower config').
|
|||||||
|
|
||||||
Ansible Tower password (Default uses setting in 'tower config').
|
Ansible Tower password (Default uses setting in 'tower config').
|
||||||
|
|
||||||
|
=item B<--nossl>
|
||||||
|
|
||||||
|
Use http connection.
|
||||||
|
|
||||||
=item B<--timeout>
|
=item B<--timeout>
|
||||||
|
|
||||||
Set timeout in seconds (Default: 50).
|
Set timeout in seconds (Default: 50).
|
||||||
|
@ -34,7 +34,7 @@ sub new {
|
|||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'group' => { name => 'group' },
|
'group' => { name => 'group' },
|
||||||
'inventory' => { name => 'inventory' },
|
'inventory' => { name => 'inventory' },
|
||||||
'prettify' => { name => 'prettify' },
|
'prettify' => { name => 'prettify' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user