https://www.puppet.com/community logo
Join Slack
Powered by
# puppet
  • t

    tvaughan

    06/17/2022, 3:54 PM
    But, it's a fact, you don't have to use it
    💯 1
  • t

    tvaughan

    06/17/2022, 3:56 PM
    🤔 You know, it would be great if you could register that facts show up if you need them and they don't all get pulled all the time
    💯 1
  • t

    tvaughan

    06/17/2022, 3:56 PM
    Like, in the metadata.json or something
  • t

    tvaughan

    06/17/2022, 3:56 PM
    Hmmmm......
  • t

    tvaughan

    06/17/2022, 3:56 PM
    I mean, you could split all of your facts into individual modules but 😞
  • p

    Pavlos Parissis

    06/17/2022, 3:56 PM
    Hi team, question about a unit test failure: I have this class
    Copy code
    class auditbeat::install {
      package { 'auditbeat':
        ensure => $auditbeat::package_ensure,
      }
    }
    and this spec:
    Copy code
    # frozen_string_literal: true
    
    require 'spec_helper'
    
    describe 'auditbeat::install' do
      let(:pre_condition) do
       'include ::auditbeat'
      end
      on_supported_os.each do |os, os_facts|
        context "on #{os}" do
          let(:facts) { os_facts }
    
          describe "with defaults" do
            it { <http://is_expected.to|is_expected.to> compile }
            it { <http://is_expected.to|is_expected.to> contain_package('auditbeat') }
          end
    
          describe "should allow package_ensure to be overridden" do
            let(:params) do
              {
                package_ensure: 'latest',
              }
            end
            it { <http://is_expected.to|is_expected.to> compile }
            it { <http://is_expected.to|is_expected.to> contain_package('auditbeat').with_ensure('latest') }
    
          end
        end
      end
    end
    and it fails with:
    Copy code
    auditbeat::install
      on ubuntu-18.04-x86_64
        with defaults
          is expected to compile into a catalogue without dependency cycles
          is expected to contain Package[auditbeat]
        should allow package_ensure to be overridden
          is expected to compile into a catalogue without dependency cycles (FAILED - 1)
          is expected to contain Package[auditbeat] with ensure => "latest" (FAILED - 2)
    
    Failures:
    
      1) auditbeat::install on ubuntu-18.04-x86_64 should allow package_ensure to be overridden is expected to compile into a catalogue without dependency cycles
         Failure/Error: it { <http://is_expected.to|is_expected.to> compile }
           error during compilation: Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: Class[Auditbeat::Install] is already declared; cannot redeclare (line: 3) (line: 3, column: 1) on node poseidonas.eu-central-1.compute.internal
         # ./spec/classes/install_spec.rb:24:in `block (5 levels) in <top (required)>'
    
      2) auditbeat::install on ubuntu-18.04-x86_64 should allow package_ensure to be overridden is expected to contain Package[auditbeat] with ensure => "latest"
         Failure/Error: it { <http://is_expected.to|is_expected.to> contain_package('auditbeat').with_ensure('latest') }
    
         Puppet::PreformattedError:
           Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: Class[Auditbeat::Install] is already declared; cannot redeclare (line: 3) (line: 3, column: 1) on node poseidonas.eu-central-1.compute.internal
         # /opt/puppetlabs/pdk/private/puppet/ruby/2.7.0/gems/puppet-7.16.0/lib/puppet/resource/catalog.rb:585:in `fail_on_duplicate_type_and_title'
    and I can't understand why. Any ideas?
  • c

    CVQuesty

    06/17/2022, 3:57 PM
    We do have a #C113FRBRU channel, btw
  • p

    Pavlos Parissis

    06/17/2022, 3:57 PM
    sorry
  • p

    Pavlos Parissis

    06/17/2022, 3:57 PM
    going there then
  • c

    CVQuesty

    06/17/2022, 3:57 PM
    No, just letting you know! 🙂
  • p

    Pavlos Parissis

    06/17/2022, 3:58 PM
    I will move the discussion there, thanks
  • d

    DanLeich

    06/17/2022, 4:17 PM
    I’m having a blank on this, and i know i’ve done it before, but can’t seem to figure it out again. How do you query nested facts from the puppetdb http API? dot notation doesn’t seem to work.
  • n

    natemccurdy

    06/17/2022, 4:19 PM
    Do you want to filter by the value of a structured fact or show the value of a structured fact?
  • n

    natemccurdy

    06/17/2022, 4:20 PM
    Either way, take a look at these docs: https://puppet.com/docs/puppetdb/7/api/query/examples-pql.html#fact-report-status-filtering-with-dot-notation You’ll need to use the
    inventory
    endpoint or
    resources
    endpoint (with inventory being more common).
  • d

    DanLeich

    06/17/2022, 4:21 PM
    i’m basically extracting the nodes which have a particular fact value
  • n

    natemccurdy

    06/17/2022, 4:21 PM
    it’s also dependent on your version of PuppetDB. e.g. this only works on PuppetDB 6.7.0+
    Copy code
    inventory[certname, facts.os.family, facts.puppetversion] {
      certname in nodes[certname] { latest_report_status = "failed" }
    }
  • n

    natemccurdy

    06/17/2022, 4:21 PM
    Filtering by a structured fact:
    Copy code
    inventory { facts.os.name = "CentOS" }
    👍 1
  • d

    DanLeich

    06/17/2022, 4:22 PM
    we’re on 7.7.1, so pretty newish
  • n

    natemccurdy

    06/17/2022, 4:22 PM
    Filtering by a structured fact:
    Copy code
    inventory { facts.os.name = "CentOS" }
  • j

    jhoblitt

    06/17/2022, 9:06 PM
    I think I'm loosing my mind... I have a file resource which set to
    replace => false
    which is changing the target of a symlink
  • v

    vchepkov

    06/17/2022, 9:07 PM
    what's
    ensure
    set to?
  • j

    jhoblitt

    06/17/2022, 9:07 PM
    link
  • v

    vchepkov

    06/17/2022, 9:07 PM
    I bet it's ignored for link
  • n

    natemccurdy

    06/17/2022, 9:10 PM
    replace
    is only relevant when defining the content/source of a file.
  • j

    jhoblitt

    06/17/2022, 9:11 PM
    facepalm
  • j

    jhoblitt

    06/17/2022, 9:12 PM
    the file type (not the provider) is difficult to reason about because it does work from the type and the provider
  • v

    vchepkov

    06/17/2022, 9:12 PM
    source code comment says otherwise, but I think it's misstated
  • v

    vchepkov

    06/17/2022, 9:12 PM
    https://github.com/puppetlabs/puppet/blob/main/lib/puppet/type/file.rb#L238-L240
  • v

    vchepkov

    06/17/2022, 9:12 PM
    https://github.com/puppetlabs/puppet/blob/main/lib/puppet/type/file.rb#L238-L240
  • j

    jhoblitt

    06/17/2022, 9:12 PM
    :replace isn't used in the provider at all
1...737475...428Latest