How to exclude Puppet modules for a few nodes?

65

Solution 1

The issue is that hiera_include will use the classes from all levels (probably uses hiera_array).

This will probably work:

[root@puppetmaster puppet]# cat hieradata/common.yaml
---
classes:
  - ldap
  - motd
  - ntp
  - puppet-conf
[root@puppetmaster puppet]# cat hieradata/environment/tst/tst-01.yaml
---
classes:
  - puppet-update
  - public-keys
  - motd
  - ntp
  - puppet-conf

In the node-def:

class { hiera('classes'): }

Downside is that you would have to specify all classes in the host-specific hiera file, if you override the default.

Does that help?

Solution 2

You can use something like this in your nodes.pp:

node default {
  hiera_include('classes')
}

node /^tst-0(1|2)\.example\.com$/ inherits default {
}

node /.*example\.com$/ inherits default {
  include ldap
}
Share:
65

Related videos on Youtube

Martin Pineault
Author by

Martin Pineault

Updated on September 18, 2022

Comments

  • Martin Pineault
    Martin Pineault over 1 year

    I'm trying to get the href data from a tr-td list (see sample code). But it always returns null value. I have tried other methods with .getElementby...() but I always bang a wall somewhere.

    <!DOCTYPE html>
    <html>
    <body>
      <p>Click the button to see the 2 results in an alerte box.</p>
      <button onclick="myFunction()">Try it</button>
      <table class="list" role="presentation">
        <thead>
          <tr>
            <th><a href="/Parliamentarians/fr/constituencies?sortBy=Name&sortDescending=True">Circonscription</a><span class="icon-ascending"></span></th>
            <th><a href="/Parliamentarians/fr/constituencies?sortBy=Province&sortDescending=False">Province / Territoire</a></th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td class="constituency">
              <a title="Cliquez pour acc&#233;der au profil de la circonscription" href="/Parliamentarians/fr/constituencies/Abbotsford(898)">Abbotsford</a>
            </td>
            <td class="constituency">Colombie-Britannique</td>
            <td class="personName">
              <a title="Cliquez pour acc&#233;der au profil du d&#233;put&#233;" href="/Parliamentarians/fr/members/Ed-Fast(35904)">Fast, Ed  <abbr>(L'hon.)</abbr></a>
            </td>
            <td class="caucus">
              <a target="_blank" title="Site Web du parti politique - Ouvre une nouvelle fen&#234;tre" href="http://www.conservateur.ca">Conservateur</a>
            </td>
          </tr>
          <tr>
            <td class="constituency">
              <a title="Cliquez pour acc&#233;der au profil de la circonscription" href="/Parliamentarians/fr/constituencies/Abitibi-Baie-James-Nunavik-Eeyou(637)">Abitibi—Baie-James—Nunavik—Eeyou</a>
            </td>
            <td class="constituency">Qu&#233;bec</td>
            <td class="personName">
            </td>
            <td class="caucus">
            </td>
          </tr>
        </tbody>
      </table>
      <script>
        function myFunction() {
          var nodeList = document.querySelectorAll('.constituency');
          var nodeList2 = document.querySelectorAll('.personName');
          var nodeList3 = document.getElementsByClassName('caucus');
    
          /* i+=2, because first is circonscription and next is province */
          for (var i = 0, j = 0; i < nodeList.length; i += 2, j++) {
            alert(nodeList[i].innerText + '|' + nodeList[i].getAttribute('href') + '|' + nodeList[i + 1].innerText + '|' + nodeList2[j].innerText + '|' + nodeList2[j].getAttribute('href') + '|' + nodeList3[j].innerText + '|' + nodeList3[j].getAttributeNode('href'));
          }
        }
      </script>
    </body>
    </html>
    

    Thank you.

    • Admin
      Admin almost 11 years
      Would it be acceptable for the ldap module to have a parameter which essentially disables it, and set the param for just those two nodes?
    • Ryan Wilson
      Ryan Wilson almost 6 years
      Just get the child element of tds with class constituency, then get their href property.
  • Martin Pineault
    Martin Pineault almost 6 years
    Do not know why, but firstChild doesn't work in my case.