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

Support for an offline/file based mirror #38

Open
LyndonArmitage opened this issue Feb 9, 2016 · 5 comments
Open

Support for an offline/file based mirror #38

LyndonArmitage opened this issue Feb 9, 2016 · 5 comments

Comments

@LyndonArmitage
Copy link

This is just a suggestion (as my puppet knowledge is quite limited).

It might be useful to add in the ability to use a puppet file server URI as a mirror instead of assuming an online mirror, as in some installs there will not be a connection available to the internet.

I've currently tried to add alter the code to support this by:

Removing the validate_re call and replacing it with a variable called $mirror_type that determines if a mirror is a HTTP URL (suitable for the current wget based download) or a file based URI (like puppet://my-module/ or /vagrant/deps):

  $mirror_type = $mirror_url ? {
    /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/ => 'http',
    default                                                          => 'file',
  }

Then altering the install logic to use a File resource instead of the Exec resource when pointing at a file based mirror:

  if $mirror_type == 'http' {

    if ! defined(Package['wget']) {
      package {'wget':
        ensure => present,
      }
    }

    notify { "Downloading Kafka via http mirror ${package_url}": }->

    exec { 'download-kafka-package':
      command => "wget -O ${package_dir}/${basefilename} ${package_url} 2> /dev/null",
      path    => ['/usr/bin', '/bin'],
      creates => "${package_dir}/${basefilename}",
      require => [ File[$package_dir], Package['wget'] ],
    }

    $required_get_step = Exec['download-kafka-package']

  } else {

    notify { "Downloading Kafka via file mirror ${package_url}": }->

    file { 'get-kafka-package':
      source  => $package_url,
      path    => "${package_dir}/${basefilename}",
      owner   => 'kafka',
      group   => 'kafka',
      require => [ File[$package_dir], User['kafka'] ],
    }

    $required_get_step = File['get-kafka-package']
  }

  exec { 'untar-file-kafka-package':
    command => "tar xfvz ${package_dir}/${basefilename} -C ${install_directory} --strip-components=1",
    creates => "${install_directory}/LICENSE",
    alias   => 'untar-kafka',
    require => [ $required_get_step, File['kafka-app-dir'] ],
    user    => 'kafka',
    path    => ['/bin', '/usr/bin', '/usr/sbin'],
  }

If you're interested I can create a pull request later this week to illustrate this better?

@danimesq
Copy link

@LyndonArmitage Too you can accept good pull requests instead of ignoring me for one year.
Btw, good idea supporting offline installs in this repo.
Use Intranet to installs, what think about?

@LyndonArmitage
Copy link
Author

Apologies @DaniellMesquita I have left a comment on that pull request now!

@dhoppe
Copy link
Member

dhoppe commented Mar 14, 2016

Since we are using the module voxpupuli/puppet-archive instead of wget, it should be possible to use a different source than http. I think we just need to update the validation of the parameter mirror_url.

@ffrank
Copy link

ffrank commented Sep 13, 2016

Instead of populating the $required_get_step, please add a before => Exec['untar-file-kafka-package'] to the respective retrieval resource.

@Bialogs
Copy link

Bialogs commented Aug 13, 2018

Since the module is using puppet-archive there is the flexibility to specify a fully-custom mirror_url.

However in these lines, if my offline package does not end in tgz the package_url is downloaded as the default case, which again makes assumptions about how I've named the offline kafka package.

To support the varied configurations of offline downloads, is it possible to modify the module so that mirror_url is passed directly into source when provided by the user. Or can the module support an additional parameter that offers this customization?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants