Quantcast
Channel: Ask Puppet: Puppet DevOps Q&A Community - RSS feed
Viewing all 257 articles
Browse latest View live

How to manage user accounts?

$
0
0
I'd like to manage user's accounts with puppet, however I didn't find any suitable module for this. I don't want to use LDAP or any sort of centralized authentication. Puppet should ensure that few admin accounts will be present at all servers. I don't care about `uid` or `gid` for user accounts, important is adding ssh key to authorized keys and adding user to some groups `sudo`, etc. The best way would be using hiera for this, so that I can easily decide which users will be at which group of servers. What's the best practice for this?

hiera dynamic lookup with external facts

$
0
0
It might be the day or the unstable caffeine levels, but this one is bugging me for more than a day now so I decided to ask here. The set up is simple: - Puppet 4.3 with hiera - puppetserver = test node - hiera.yaml: https://gist.github.com/kreczko/3cfd094dd9e50b29f82f#file-hiera-yaml In datadir: - nodes/puppetserver.yaml: https://gist.github.com/kreczko/3cfd094dd9e50b29f82f#file-puppetserver-yaml - groups/service.yaml: https://gist.github.com/kreczko/3cfd094dd9e50b29f82f#file-service-yaml - common.yaml:https://gist.github.com/kreczko/3cfd094dd9e50b29f82f#file-common-yaml - site class: https://gist.github.com/kreczko/3cfd094dd9e50b29f82f#file-init-pp In the first iteration of 'puppet agent -t' my site class creates an external fact based on the information in "nodes/%{::fqdn}". This works. In the second iteration I expect hiera to load values from 'groups/service.yaml' and printout 'message' (also defined in the site class). However, when that happens I see the value from common.yaml. Clearly hiera did not its job. It becomes more confusing if instead I try 'puppet apply -e "notice hiera('message')" which prints correctly the value from groups/service.yaml. So the fact itself works, but hiera does not make any decisions on it. From https://docs.puppetlabs.com/hiera/3.0/hierarchy.html and https://docs.puppetlabs.com/hiera/3.0/variables.html I would have expected this to work. What am I doing wrong?

How to create directory before mount in hieradata

$
0
0
Hello, I'm a bit of a puppet noob... From a yaml in hieradata I know how to both create a directory & to create a mount. However, I'm unsure how to force the ordering of these from within a yaml. The only solution I could come up with is to create a module I called ramdisk just to order these properly. It does what I want... But what if I want to create a second directory/mount? I don't want to create a new module. Can someone please point me to documentation that will help me learn how to make this more generic so I can pass the arguments required to it. Here's what I have... class ramdisk { file { '/local/common/ramcache': ensure => 'directory', owner => 'nobody', group => 'nobody', mode => '0750', before => Mount['/local/common/ramcache'], } -> mount { '/local/common/ramcache': ensure => 'mounted', atboot => 'true', device => 'none', fstype => 'tmpfs', options => 'nodev,nosuid,noexec,nodiratime,size=10M', dump => '0', pass => '0', require => File['/local/common/ramcache'], } }

Razor, hooks and hostnames

$
0
0
Hi, I am currently dealing with the problem that I need to assign hostnames within razor to a node before it is installed. This is supposed to make sure the host gets the right hostname and puppet certificate from the start. I was thinking about a way to provide razor dynamically with a hostname using hooks. The hostname pattern provided by razor seems to be hard to set to individual hostnames. The idea is as follows: 1. A node boots up and registers at Razor. 2. A hook (either "node-booted" or "node-registered" is triggered. 3. As far as I understand hooks until now I could write a script, run a command, alter the json hash I got from razor and return a new hash with an update hostname. For this purpose I set up an hiera instance on the razor node and will update the datadir using puppet. Then - using whatever key i want - I could assign a hostname to a specific MAC, serialnumber or anything provided by the razor facts. The advantage I see is that I can already setup a number of hosts before they are installed or powered on and razor would get the hostnames for the installation on the fly. I try to minimize the number of manual actions in razor and keep it in an environment where people are already are used to (like hiera in puppet). My Question: Is this the way to go or is there an easier way of achiving the goal of having the hostname defined in razor before a node actually shows up?

sub sub folders in hieradata

$
0
0
Hey comm, I'm using Puppet 4 Open Source. Being boggled about the following. I simply would like to have subfolders in my hiera datadir like the following. `/hieradata/osmajrel/CentOS/7.yaml`. So that I can make an array of packages and have a specific package installed on CentOS 7 (but **not** on Debian 7 for example) I'm trying to construct my hiera.yaml `:hierarchy:` with different variables from facter like: "`osmajrel/%{::os.name}/%{::os.release.major}`". **I tried the following in my `hiera.yaml` `:hierarchy:` to no avail:** - `"osmajrel/%{::os.name}%{::os.release.major}"` (file containing `base_package` array in `/hieradata/osmajrel/CentOS7.yaml`) - `"osmajrel/%{::os.name}%-{::os.release.major}"` (file containing `base_package` array in `/hieradata/osmajrel/CentOS-7.yaml`) - `"osmajrel/%{::os.name}%/{::os.release.major}"` (file containing `base_package` array in `/hieradata/osmajrel/CentOS/7.yaml`) **It works only if my `hiera.yaml` `:hierarchy:` contains:** - `"osname/%{::os.name}"` (file containing `base_package` array in `/hieradata/osname/CentOS.yaml`) - `"osmajrel/%{::os.release.major}"` (file containing `base_package` array in `/hieradata/osmajrel/7.yaml`) I've got a notify in my packages class to show me which packages would be installed by the agent. Any idea why merging variables don't seem to work in hiera.yaml?

Hiera calling a parameter set in a module

$
0
0
I am wondering if it is possible or if there is a better way for having a yaml file used by Hiera to have dymanic configuration My current hiera config is as follows. :backends: - yaml :hierarchy: - "node/%{::clientcert}" - "role/%{::dec_role}" - "dc/%{::dec_dc}" - common - firewall For a role, I want to create an autofs resource however, I also want to pass in a specific parameter. Yaml file for role is as follows. autofs::mounts: icedrop: mount: /- mapfile: /etc/autofs.d/auto.ice mapcontents: '/srv/ice -fstype=cifs,noperm,credentials=/etc/autofs.d/cred/ice_flat_files %{::ice::params::ice_server}/ICE_Flat_Files' options: --timeout=600 order: 4 Note that I have tired to pass in a parameter I already have set in ice::params::ice_server However, nothing gets passed in, so it means this is a null value I assume at the moment. So my question is, can one pass a parameter into Hiera like you would with a normal class or module or can Hiera call this type of parameter. I could create node yaml file and have this set statically but would prefer to have the one role yaml file and have this working dynamically for all my servers. Hope I am clear and thanks. EDIT: To add.... The parameter ice::params::ice_server can be found in a module I have written. Note $env is a fact we have to determine the environment. class ice::params::ice_server { if $env == 'tst' { $ice_server = 'testserver03' } elsif $env == 'prd' { $ice_server = 'prodserver04' } } Setting the parameter is not an issue and calling itin side other modules is OK, I have done that many times before, but calling it in Heira is not something I have done before. Looking at the puppet documentation the syntax is supposed to be %{::ice::params::ice_server} however in my yaml file this doesn't return anything. I'm thinking do I need to inherit it somehow or perhaps the scope is wrong? Hope this makes it clearer.

setting a function as value via hiera

$
0
0
Hi, I'm currently using the puppet/apache module to manage apache. I have lot's of servers with large blocks of rewrite rules, but those rewrite rules are most times the same, so I want to save them to a seperate file, read that file and add it as a custom fragment to the apache configuration. This works like a charm with puppet code. apache::vhost { 'xyz.com': port => '80', docroot => '/var/www', custom_fragment => file('role/apache/rules.conf'), } but I want to give all virtualhost configuration to hiera and use create_resources to build the vhost configurations. Like this: apache::vhosts: xyz.com: port: '80' docroot: '/var/www' custom_fragment: file('role/apache/rules.conf') this is adding only the text "file('role/apache/rules.conf') to the apache configuration it is not executing the function. Is there any way to achieve this. Thank you in advance.

How to set parameters with hiera for a class included in default.pp

$
0
0
setup: - no puppetmaster - puppet version 4.3.1 - hiera 1.3.0 currently the default.pp looks like that: node default { class { 'ntp': servers => [ 'ntp.ubuntu.com' ] } } class { 'apt': purge_sources_list => true, purge_sources_list_d => true, purge_preferences_d => true, } hiera_include('roles', []) hiera_include('sites', []) hiera.yaml looks like that: --- :backends: - yaml :hierarchy: - "%{::clientcert}" - "%{::environment}" - "%{::domain}" - "virtual_%{::is_virtual}" - common :yaml: :datadir: "/etc/puppetlabs/code/environments/%{::environment}/hieradata" vagrant.yaml --- roles: - roles::nginx - roles::java8 apt::sources: "openjdk-8": location: "http://ppa.launchpad.net/openjdk-r/ppa/ubuntu" release: trusty repos: main include_src: false include_deb: true key: 'DA1A4A13543B466853BAF164EB9B1D8886F44E2A' everything works like charm but now i would like to remove the three parameters from the apt class and setting them with hiera. `apt::sources:` are correclty looked up via hiera but if i add `apt:` it does nothing adding this to my hiera file does not help: apt:: purge_sources_list: false purge_sources_list_d: false purge_preferences_d: false also tried `apt::init:` as key it it possible to set the parameter via hiera without using ``hiera_include('classes')`?

hiera host-network-information

$
0
0
Hello all! I trying to figure out how to put my host network information under hiera (using puppet4 opensource with no enc) Maybe I got this all wrong but this what I was thinking: Base.pp profiles::base include profiles::network Network.pp # contains my logic to check if it's static or bonding network interface. Calls razoredge network module to actually do the work. class profiles::network { If hiera(profiles::network::network_info::type) == bonding { #based on fqdn hiera lookup network::bond::static { ‘bond0’: ensure =>‘up’, ipaddress =>“profiles::network::network_info::ipadress” else network::if::static ensure =>‘up’ ipadress =>“profiles::network::network_info::ipadress” } host1.toto.com.yaml #host network information based on fqdn hiera declaration profiles::network::network_info type: bonding ipadress: 10.10.10.10 gateway: 10.10.10.1 routes: - 10.10.10.2 - 10.10.10.3 I know my code is all wrong but anybody using hiera for host-network-information? Or if it's really bad practice to do so. Thanks! Eric

More hiera examples

$
0
0
Hi all! I'm use puppet 4.* on Centos 7 and i want to use hiera with it all. Suppose i have 1 puppet master host and 1 node test1. On master i have: #/etc/puppetlabs/code/hiera.yaml --- :backends: - yaml - json :yaml: :datadir: "/etc/puppetlabs/code/hiera/%{::environment}" :json: :datadir: "/etc/puppetlabs/code/hiera/%{::environment}" :hierarchy: - "nodes/%{::fqdn}" - "common" # /etc/puppetlabs/code/hiera/production/nodes/test1.yaml --- her::parameter_one: "This node is special, so we're overriding the common configuration that the other nodes use." classes: - her #/etc/puppetlabs/code/environments/production/manifests/classes/her/her.pp class her ($parameter_one = "default text") { file {'/tmp/her': ensure => file, content => $parameter_one, } } And on test1 i run "puppet agent --debug --no-daemonize --onetime" **Question**: How i can run /etc/puppetlabs/code/environments/production/manifests/classes/her/her.pp with "non default" parameters with hiera? Some server info: # uname -a Linux pm2-chel1.is74.ru 3.10.0-327.10.1.el7.x86_64 #1 SMP Tue Feb 16 17:03:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux # hiera --version 1.3.4 # puppet master --version 4.3.2 # rpm -qa | grep hiera hiera-1.3.4-5.el7.noarch # rpm -qa | grep pupp puppetlabs-release-pc1-1.0.0-1.el7.noarch puppetdb-termini-3.2.4-1.el7.noarch puppet-agent-1.3.5-1.el7.x86_64 puppetdb-3.2.4-1.el7.noarch puppetserver-2.2.1-1.el7.noarch # cat /etc/centos-release CentOS Linux release 7.2.1511 (Core)

Automatic parameter lookup: best practice?

$
0
0
When utilizing Puppet's automatic parameter lookup in Hiera, what is the better pattern: keep all parameters in init.pp and refer to them in subclasses (similarly to the old params.pp scheme), or skip the parameters in init.pp and use subclasses to set them? Pattern 1: all parameters in init.pp, e.g. class myapplication ( $ssl_enable, $ssl_cert, $ssl_key, $ssh_access_enable, $ssh_access_key ... ) { contain myapplication::ssh contain myapplication::ssl } class myapplication::ssl ( $enable = $::myapplication::ssl_enable, ... ) { ... } Pattern 2: parameters in subclasses, e.g. class myapplication { contain myapplication::ssh contain myapplication::ssl } class myapplication::ssl ( $enable, $cert, $key ) { ... } With APL and Hiera, the latter seems cleaner and more sensible -- it's easier to figure out where to set the parameter, IMO -- but the obvious downside is that parameters aren't all in one place, so it's theoretically harder to find them. I haven't been able to find any opinions on the matter. (I'm not using the params.pp model because the modules I'm making are for one OS only, and the only real application of params.pp that I can see, now that we have APL, is dealing with OS variants.)

configuring passenger from hiera with puppetlabs-apache module

$
0
0
I'm looking to setup a Passenger app using the puppetlabs-module, configuring via hiera. If I use the following vhost definition it works fine: web::vhosts: node.com: docroot: /var/www/app serveraliases: "%{fqdn}" passenger_app_env: production passenger_pre_start: "http://%{fqdn}/contact" passenger_min_instances: 3 directories: - path: /var/www/app passenger_enabled: "on" but if I try to define the pool_idle_time for passenger with the following config web::vhosts: node.com: docroot: /var/www/app serveraliases: "%{fqdn}" passenger_app_env: production passenger_pre_start: "http://%{fqdn}/contact" passenger_min_instances: 3 passenger_pool_idle_time: 0 directories: - path: /var/www/app passenger_enabled: "on" I get an error > Error: Could not retrieve catalog from> remote server: Error 400 on SERVER:> Invalid parameter> passenger_pool_idle_time on node> abc.co.uk but from looking at the templates/mod/passenger.conf.erb it looks as if that is an option that can be configured.

Hiera returning wrong environment from YAML source

$
0
0
Hey Comm, Would be grateful if anyone could help me with this. Aim: I'm trying to assign an environment other than default production using an ENC script I've written in bash. The script calls hiera as follows where it fails: hiera environment -y /etc/puppetlabs/code/nodes/test.hs1.nl.yaml --config /etc/puppetlabs/code/hiera-enc.yaml -d DEBUG: 2016-01-04 23:28:02 +0100: Hiera YAML backend starting DEBUG: 2016-01-04 23:28:02 +0100: Looking up environment in YAML backend DEBUG: 2016-01-04 23:28:02 +0100: Looking for data source default DEBUG: 2016-01-04 23:28:02 +0100: Found environment in default production Content of `/etc/puppetlabs/code/nodes/test.hs1.nl.yaml`: --- environment: 'hs1-ext' Content of `/etc/puppetlabs/code/hiera-enc.yaml`: --- :backends: - yaml :hierarchy: - "%{::fqdn}" - "default" :yaml: :datadir: /etc/puppetlabs/code/nodes Am I overseeing anything? Thanks in advance! Richard

Unable to get data from hiera. It must be simple....

$
0
0
My end goal is to iterate through a puppet hash and configure multiple VRFs. I was able to do that when the hash is locally defined using below code: $tenant_vrf_info = { 1=>{vrf=>"evpn-tenant-1", l3_vni=>"5010", rd=>"2000:5010", import=>"2000:5010"}, 2=>{vrf=>"evpn-tenant-2", l3_vni=>"5020", rd=>"2000:5020", import=>"2000:5020", } $tenant_vrf_info.each |$tenant,$value| { $tenant_id = "$tenant" $tenant_vrf_context = "${value[vrf]}" $tenant_l3_vni = "${value[l3_vni]}" cisco_command_config { $tenant_id: command => " vrf context $tenant_vrf_context vni ${value[l3_vni]} address-family ipv4 unicast " } } I decided to get this data from Hiera. This is when the nightmare began... I cannot get the data out of the hash. I just want the data out hiera so I can iterate through it using .each. Below is my setup. When I run below code I get this error: **Evaluation Error: Empty string title at 0. Title strings must have a length greater than zero.** **YAML File:** --- vrfs: vrf-evpn-tenant-2: l3_vni: 20101 rd: '2000:20101' vrf-evpn-tenant-3: l3_vni: 20102 rd: '2000:20102' **HIERA:** hiera -d vrfs {"vrf-evpn-tenant-2"=>{"l3_vni"=>20101, "rd"=>"2000:20101"}, "vrf-evpn-tenant-3"=>{"l3_vni"=>20101, "rd"=>"2000:20101"}} **Puppet Manifest:** class rbc_vrf { include install include stdlib $tenant_vrf_info_hiera = hiera('vrfs') notify{"${tenant_vrf_info_hiera['l3_vni']}":} }

how can i access fact hashes in hiera hierarchies

$
0
0
using puppet open source 3.8.4, hiera 1.3.4 and I am trying to figure out how to access a custom structured data fact to build out my hiera yaml hierarchy. when i run puppet in debug mode it doesn't find the component hierarchy, it just finds `environment/common` and `common`. As soon as i switch the fact from a hash to basic individual string variables and update the hierarchy to be `%{::component}` it finds the path. At what version did hiera support hashed facts in its config file, or am i missing something. **note** I have tried various different syntaxes of `::sapenvs:component` i.e; `::sapenvs[component]`, `::sapenvs.component`. **/etc/facter/facts.d/kickstart.yaml** --- sapenvs: component: 'ECC' **hiera.yaml** --- :backends: - yaml :yaml: :datadir: /opt/puppet/hieradata :hierarchy: - "%{::environment}/%{::sapenvs:component}/common" - "%{::environment}/common" - "common"

Using Puppet Apply with Hiera for building Docker images

$
0
0
I'm trying to build a docker image with Puppet Apply and Hiera. The puppet module can be found here [1], hiera data files can be found here [2] and Dockerfile is as follows: FROM ubuntu:15.10 MAINTAINER imesh@abc.org ENV DEBIAN_FRONTEND noninteractive RUN apt-get -y update RUN apt-get -y install puppet COPY puppet/ /etc/puppet/ ENV FACTER_product_name: wso2esb ENV FACTER_product_version: 4.9.0 ENV FACTER_product_profile: default ENV FACTER_environment: dev ENV FACTER_vm_type: docker RUN puppet apply --modulepath=/etc/puppet/manifests/site.pp --hiera_config /etc/puppet/hieradata/hiera.yaml --verbose --detailed-exitcodes || [ $? -eq 2 ] # Servlet and pass-through transport ports EXPOSE 9763 9443 8280 8243 ENTRYPOINT /usr/local/bin/init.sh **Question** Once I run the Docker build command I get the following error: Step 15 : RUN puppet apply --modulepath=/etc/puppet/manifests/site.pp --hiera_config /etc/puppet/hieradata/hiera.yaml --verbose --detailed-exitcodes || [ $? -eq 2 ] ---> Running in 771731292a99 Error: Could not find data item classes in any Hiera data file and no default supplied at /etc/puppet/manifests/site.pp:20 on node ca5fd9ca11dc Error: Could not find data item classes in any Hiera data file and no default supplied at /etc/puppet/manifests/site.pp:20 on node ca5fd9ca11dc The command '/bin/sh -c puppet apply --modulepath=/etc/puppet/manifests/site.pp --hiera_config /etc/puppet/hieradata/hiera.yaml --verbose --detailed-exitcodes || [ $? -eq 2 ]' returned a non-zero code: 1 Appreciate any thoughts on this! [1] https://github.com/wso2/puppet-modules/tree/master/wso2esb [2] https://github.com/wso2/puppet-modules/blob/master/hiera/hieradata/dev/wso2/wso2esb/4.9.0/default.yaml

Is Puppet Evaluating Variables in my YAML data?

$
0
0
I have this in a yaml file in my hiera data: wsgi_keystone_conf_contents: | Listen 5000 Listen 35357 WSGIDaemonProcess keystone-public processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP} WSGIProcessGroup keystone-public WSGIScriptAlias / /var/www/cgi-bin/keystone/main WSGIApplicationGroup %{GLOBAL} WSGIPassAuthorization On LogLevel info ErrorLogFormat "%{cu}t %M" ErrorLog /var/log/httpd/keystone-error.log CustomLog /var/log/httpd/keystone-access.log combined WSGIDaemonProcess keystone-admin processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP} WSGIProcessGroup keystone-admin WSGIScriptAlias / /var/www/cgi-bin/keystone/admin WSGIApplicationGroup %{GLOBAL} WSGIPassAuthorization On LogLevel info ErrorLogFormat "%{cu}t %M" ErrorLog /var/log/httpd/keystone-error.log CustomLog /var/log/httpd/keystone-access.log combined And I try to create a my `wsgi-keystone.conf` file in my puppet manifest like so : file { '/etc/httpd/conf.d/wsgi-keystone.conf': ensure => present, content => $wsgi_keystone_conf_contents, } But this results in a file that looks like this ... Listen 5000 Listen 35357 WSGIDaemonProcess keystone-public processes=5 threads=1 user=keystone group=keystone display-name= WSGIProcessGroup keystone-public WSGIScriptAlias / /var/www/cgi-bin/keystone/main WSGIApplicationGroup WSGIPassAuthorization On LogLevel info ErrorLogFormat "t %M" ErrorLog /var/log/httpd/keystone-error.log CustomLog /var/log/httpd/keystone-access.log combined WSGIDaemonProcess keystone-admin processes=5 threads=1 user=keystone group=keystone display-name= WSGIProcessGroup keystone-admin WSGIScriptAlias / /var/www/cgi-bin/keystone/admin WSGIApplicationGroup WSGIPassAuthorization On LogLevel info ErrorLogFormat "t %M" ErrorLog /var/log/httpd/keystone-error.log CustomLog /var/log/httpd/keystone-access.log combined The above file has syntax error and httpd will not restart. How am I supposed to put data in my YAML file? Do I need to escape the `%`'s?

How to distribute hiera files with puppet modules via puppet forge?

$
0
0
Hi all, I'm using puppet 3.4.3, and my modules are tightly coupled to hiera. I would like to know the options that I have for distributing the hiera files (hiera.yaml and a few basic yaml backend files which users can customize to suit their needs) with puppet modules. The requirement is, when the user does puppet module install , the hiera files should be copied to default data directory (/etc/puppet/hieradata). If there is a better way to do this, kindly let me know. Thanks.

Duplicate declaration error when using Ini_setting

$
0
0
I'm getting this error when using ini_setting and hiera "Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Function Call, Duplicate declaration: Ini_setting[[database] connection] is already declared; cannot redeclare at /etc/puppetlabs/code/environments/production/manifests/site.pp:50:3 on node lib-glance.liberty.local" I know why i am getting the error, here is my puppet code node 'lib-glance' { include glance::api include glance::registry } class glance::api ($settings,){ # validate_hash($apisettings) $defaults = { 'path' => '/etc/glance/glance-api.conf' } create_ini_settings($settings, $defaults) } class glance::registry($settings,){ # validate_hash($registrysettings) $regdefaults = { 'path' => '/etc/glance/glance-registry.conf' } create_ini_settings($settings, $regdefaults) } And here is the associated heira glance::api::settings: DEFAULT: notification_driver: "noop" verbose: "true" database: connection: "mysql://glance:%{hiera('databasePasswords::glance')}@%{hiera('mysql::virtualIP')}/glance" glance::registry::settings: database: connection: "mysql://glance:%{hiera('databasePasswords::glance')}@%{hiera('mysql::virtualIP')}/glance Clearly when the second `create_ini_settings` runs it is detects the duplicate variable definition from the database \ Connection setting and throws an error. But my intention is to write these values into separate config files(This works if i remove the duplication). So how do I fix this?

How do I submit a fix/request a fix to hiera in CentOS 7.2?

$
0
0
When I attempt to use Hiera on CentOS 7.2 from a clean install it doesn't work. The default hiera.yml file is in /etc/puppet. Only by making a soft link and creating a new directory called /etc/puppetlabs/code/hiera.yml and link to it does hiera then work from the default install. I have a couple ways to fix the CentOS7.2 package or Hiera at its root, what is the proper way to do this?
Viewing all 257 articles
Browse latest View live