Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy Support #133

Closed
0x7081 opened this issue Jun 27, 2019 · 7 comments
Closed

Proxy Support #133

0x7081 opened this issue Jun 27, 2019 · 7 comments
Labels

Comments

@0x7081
Copy link

0x7081 commented Jun 27, 2019

It would be great if the zookeeper module could support proxy.
I use this module in a corporate environment where all the traffic runs through a proxy.

It would look something like this:

params.pp

  # installation options
  $archive_checksum = {}
  $archive_dl_site = undef
  $archive_dl_timeout = 600
  $archive_dl_url = undef
  $archive_install_dir = '/opt'
  $archive_symlink = true
  $archive_symlink_name = "${archive_install_dir}/zookeeper"
  $archive_version = '3.4.8'
  $cdhver = undef
  $install_java = false
  $install_method = 'package'
  $java_bin = '/usr/bin/java'
  $java_opts = ''
  $java_package = undef
  $repo = undef
  $proxy_server = undef

init.pp

  # installation options
  Hash                                       $archive_checksum        = $::zookeeper::params::archive_checksum,
  Optional[String]                           $archive_dl_site         = $::zookeeper::params::archive_dl_site,
  Integer                                    $archive_dl_timeout      = $::zookeeper::params::archive_dl_timeout,
  Optional[String]                           $archive_dl_url          = $::zookeeper::params::archive_dl_url,
  String                                     $archive_install_dir     = $::zookeeper::params::archive_install_dir,
  Boolean                                    $archive_symlink         = $::zookeeper::params::archive_symlink,
  String                                     $archive_symlink_name    = $::zookeeper::params::archive_symlink_name,
  String                                     $archive_version         = $::zookeeper::params::archive_version,
  Optional[String]                           $cdhver                  = $::zookeeper::params::cdhver,
  Boolean                                    $install_java            = $::zookeeper::params::install_java,
  String                                     $install_method          = $::zookeeper::params::install_method,
  String                                     $java_bin                = $::zookeeper::params::java_bin,
  String                                     $java_opts               = $::zookeeper::params::java_opts,
  Optional[String]                           $java_package            = $::zookeeper::params::java_package,
  Optional[Variant[String,Hash]]             $repo                    = $::zookeeper::params::repo,
  String                                     $proxy_server            = $::zookeeper::params::proxy_server,

archive.pp

  archive { "${::zookeeper::archive_install_dir}/${filename}.tar.gz":
    ensure        => present,
    user          => 'root',
    group         => 'root',
    source        => $download_url,
    proxy_server  => $::zookeeper::proxy_server,
    checksum      => $::zookeeper::archive_checksum['hash'],
    checksum_type => $::zookeeper::archive_checksum['type'],
    extract_path  => $::zookeeper::archive_install_dir,
    # Extract files as the user doing the extracting, which is the user
    # that runs Puppet, usually root
    extract_flags => '-x --no-same-owner -f',
    creates       => "${::zookeeper::archive_install_dir}/${filename}",
    extract       => true,
    cleanup       => true,
    notify        => Exec['chown_zookeeper_directory'],
  }
@0x7081
Copy link
Author

0x7081 commented Jun 27, 2019

I would create a pull request but I'm not sure if "undef" works in non-proxy environments.

@deric
Copy link
Owner

deric commented Jun 27, 2019

PRs are always welcomed! Let's first check if it's not doable with existing codebase.

You can opt either for custom repo or archive install method

class { 'zookeeper':
  cdhver     => '5',
  repo       =>  {
    name  => 'myrepo',
    url   => 'http://cusom.url',
    descr => 'description'
  }
}

with archive method you can override

class { 'zookeeper':
  install_method  => 'archive',
  archive_version => '3.4.8',
  archive_dl_site  => 'http://some_proxy_site',
}

But you're right we don't support proxy_server of puppet-archive.

I'm not sure if "undef" works in non-proxy environments.

Not sure if I understand the question. undef is correct puppet language value, it should work on the Moon as well.

@0x7081
Copy link
Author

0x7081 commented Jun 27, 2019

Thanks for the reply!
In my case I use the archive install method and I saw that it is possible to set a custom url. But if I want to use the package from apache itself I need to use the proxy_server option, otherwise I need to host the file inside the company.

Not sure if I understand the question. undef is correct puppet language value, it should work on the Moon as well.

Maybe it was a not clear what I meant. Yes undef is correct puppet code but in my example above I set $proxy_server = undef. And now if I execute the archive code without an proxy_server the puppet agent returns an error. So my example is not ready for a PR right now.

@deric
Copy link
Owner

deric commented Jun 27, 2019

@BreadTrooper Right, puppet-archive uses custom type for declaring archive. Just by looking at the code it's hard for me to guess how does it handle undef values.

I've tried writing a quick implementation in d545245, but I haven't properly tested it yet.

@deric
Copy link
Owner

deric commented Jun 27, 2019

@BreadTrooper Please try version from master branch. Automated tests seem to pass, but it doesn't cover everything.

@0x7081
Copy link
Author

0x7081 commented Jun 27, 2019

@deric looking good!
I tried my code with and without a proxy_server defined. I got no error in both puppet runs.

@deric deric added the feature label Jun 27, 2019
@deric
Copy link
Owner

deric commented Jun 27, 2019

Good, I'm closing the issue, feel free to reopen or create a new issue if you encounter any problems.

@deric deric closed this as completed Jun 27, 2019
cegeka-jenkins pushed a commit to cegeka/puppet-zookeeper that referenced this issue Sep 7, 2020
cegeka-jenkins pushed a commit to cegeka/puppet-zookeeper that referenced this issue Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants