How can this become smarter (shorter) ?

asked 2017-11-24 09:12:46 -0600

marcnesium gravatar image

Hi, this looks like lots of code and could be more efficient (Zesty & Xenial )?

Thanks for your support !

 $mirrors         = {
        'xenial_main' => {
          location      => 'http://de.archive.ubuntu.com/ubuntu',
          release       => 'xenial',
          repos         => ['main', 'restricted'],
          architectures => ['i386','amd64'],
          key           => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
          keyserver     => 'keyserver.ubuntu.com',
          with_udebs    => true,
        },
        'xenial_main_updates' => {
          location      => 'http://de.archive.ubuntu.com/ubuntu',
          release       => 'xenial-updates',
          repos         => ['main', 'restricted'],
          architectures => ['i386','amd64'],
          key           => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
          keyserver     => 'keyserver.ubuntu.com',
          with_udebs    => true,
        },
        'xenial_universe' => {
          location      => 'http://de.archive.ubuntu.com/ubuntu',
          release       => 'xenial',
          repos         => ['universe'],
          architectures => ['i386','amd64'],
          key           => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
          keyserver     => 'keyserver.ubuntu.com',
          with_udebs    => true,
        },
        'xenial_universe_updates' => {
          location      => 'http://de.archive.ubuntu.com/ubuntu',
          release       => 'xenial-updates',
          repos         => ['universe'],
          architectures => ['i386','amd64'],
          key           => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
          keyserver     => 'keyserver.ubuntu.com',
          with_udebs    => true,
        },
        'xenial_multiverse' => {
          location      => 'http://de.archive.ubuntu.com/ubuntu',
          release       => 'xenial',
          repos         => ['multiverse'],
          architectures => ['i386','amd64'],
          key           => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
          keyserver     => 'keyserver.ubuntu.com',
          with_udebs    => true,
        },
        'xenial_multiverse_updates' => {
          location      => 'http://de.archive.ubuntu.com/ubuntu',
          release       => 'xenial-updates',
          repos         => ['multiverse'],
          architectures => ['i386','amd64'],
          key           => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
          keyserver     => 'keyserver.ubuntu.com',
          with_udebs    => true,
        },
        'xenial_backports' => {
          location      => 'http://de.archive.ubuntu.com/ubuntu',
          release       => 'xenial-backports',
          repos         => ['main','restricted','universe','multiverse'],
          architectures => ['i386','amd64'],
          key           => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
          keyserver     => 'keyserver.ubuntu.com',
          with_udebs    => true,
        },
        'xenial_security' => {
          location      => 'http://security.ubuntu.com/ubuntu',
          release       => 'xenial-security',
          repos         => ['main','restricted'],
          architectures => ['i386','amd64'],
          key           => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
          keyserver     => 'keyserver.ubuntu.com',
          with_udebs    => true,
        },
        'xenial_security' => {
          location      => 'http://security.ubuntu.com/ubuntu',
          release       => 'xenial-security',
          repos         => ['main','restricted'],
          architectures => ['i386','amd64'],
          key           => [],
          keyserver     => 'keyserver.ubuntu.com',
          with_udebs    => true,
        },
        'xenial_security_universe' => {
          location      => 'http://security.ubuntu.com/ubuntu',
          release       => 'xenial-security',
          repos         => ['universe'],
          architectures => ['i386','amd64'],
          key           => [],
          keyserver     => 'keyserver.ubuntu.com',
          with_udebs    => true,
        },
        'xenial_security_multiverse' => {
          location      => 'http://security.ubuntu.com/ubuntu',
          release       => 'xenial-security',
          repos         => ['multiverse'],
          architectures => ['i386','amd64'],
          key           => [],
          keyserver     => 'keyserver.ubuntu.com',
          with_udebs    => true,
        },
        'xenial_yarn'   => {
          location      => 'https://dl.yarnpkg.com/debian/',
          release       => 'stable',
          repos         => ['main'],
          architectures => ['amd64'],
          key           => ['72ECF46A56B4AD39C907BBB71646B01B86E50310'],
          keyserver     => 'hkp://p80.pool.sks-keyservers.net:80',
        },
        'xenial_puppet'   => {
          location      => 'http://apt.puppetlabs.com/',
          release       => 'xenial',
          repos         => ['PC1'],
          architectures => ['amd64'],
          key           => ['6F6B15509CF8E59E6E469F327F438280EF8D349F'],
          keyserver     => 'hkp://p80.pool.sks-keyservers.net:80',
        },
        'zesty_puppet'  => {
          location      => 'http://apt.puppetlabs.com/',
          release       => 'zesty',
          repos         => ['PC1'],
          architectures => ['amd64'],
          key           => ['6F6B15509CF8E59E6E469F327F438280EF8D349F'],
          keyserver     => 'hkp://p80.pool.sks-keyservers.net:80',
        },
        'zesty_yarn'   => {
          location      => 'https://dl.yarnpkg.com/debian/',
          release       => 'stable',
          repos         => ['main'],
          architectures => ['amd64'],
          key           => ['72ECF46A56B4AD39C907BBB71646B01B86E50310'],
          keyserver     => 'hkp://p80.pool.sks-keyservers.net:80',
        },
        'zesty_security_multiverse' => {
          location      => 'http://security.ubuntu.com/ubuntu',
          release       => 'zesty-security',
          repos         => ['multiverse'],
          architectures => ['i386','amd64'],
          key           => [],
          keyserver     => 'keyserver.ubuntu.com',
          with_udebs    => true,
        },
        'zesty_security_universe' => {
          location      => 'http://security.ubuntu.com/ubuntu',
          release       => 'zesty-security',
          repos         => ['universe'],
          architectures => ['i386','amd64'],
          key           => [],
          keyserver     => 'keyserver.ubuntu.com',
          with_udebs    => true,
        },
        'zesty_security' => {
          location      => 'http://security.ubuntu.com/ubuntu',
          release       => 'zesty-security',
          repos         => ['main','restricted'],
          architectures => ['i386','amd64'],
          key           => [],
          keyserver     => 'keyserver.ubuntu.com',
          with_udebs    => true,
        },
        'zesty_security' => {
          location      => 'http://security.ubuntu.com/ubuntu',
          release       => 'zesty-security',
          repos         => ['main','restricted'],
          architectures => ['i386','amd64'],
          key           => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
          keyserver     => 'keyserver.ubuntu.com',
          with_udebs    => true,
        },
        'zesty_backports' => {
          location      => 'http://de.archive.ubuntu.com/ubuntu',
          release       => 'zesty-backports',
          repos         => ['main','restricted','universe','multiverse'],
          architectures => ['i386','amd64'],
          key           => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
          keyserver     => 'keyserver.ubuntu.com',
          with_udebs    => true,
        },
        'zesty_multiverse_updates' => {
          location      => 'http://de.archive.ubuntu.com/ubuntu',
          release       => 'zesty-updates',
          repos         => ['multiverse'],
          architectures => ['i386','amd64'],
          key           => ['40976EAF437D05B5','3B4FE6ACC0B21F32'],
          keyserver ...
(more)
edit retag flag offensive close merge delete

Comments

Maybe you could programmatically construct your $mirror hash. But that doesn't necessarily increase readability. In any case, I'd deduplicate literals into variables: Some URIs occur multiple times. Place that value in a variable instead (provided it's necessarily the same among all occurrences).

Kai Burghardt gravatar imageKai Burghardt ( 2017-11-25 06:51:02 -0600 )edit

You could put all that into hiera.

Red Cricket gravatar imageRed Cricket ( 2017-11-25 21:50:23 -0600 )edit