I am trying learn Puppet by setting up my various Raspberry Pis. These come with a standard user (pi) and a standard password (raspberry). Until this password is changed, a security warning appears when you log in. I want Puppet to change this for me when the machine is new, but NOT if it has already been changed. I have been trying to use a custom fact, as my plan is to have a "wanted" file with all the options as booleans. I then want a separate "done" file for each option that has been executed. So, for my password example, I intend my final file to test whether a new password is wanted (it would not be on machines other than Pis) and whether this has been done (the password should NOT be overwritten if, for whatever reason, it has been changed after the initial setup).
Installing puppet on the Pi results in only one non-home "facts.d" directory (/var/lib/puppet/facts.d). Any files I put in there get deleted, which rather defeats my object. Neither https://docs.puppet.com/puppet/latest/man/facts.html nor https://docs.puppet.com/facter/3.5/custom_facts.html give any clue to this behaviour. The closest I have found is https://github.com/saz/puppet-php/issues/13. Where, please, are the docs describing this behaviour and how to override this default?
Regards,
John Davies
Update: The file is being created by puppet. The code is:
class pi_user::password {
if $facts['hostname'] in ['pi245'] {
unless $facts['pi_password_done'] {
file { '/var/lib/puppet/facts.d/pi_password_done.txt':
ensure => 'present',
content => 'pi_password_done=true
',
}
user { 'pi':
password => '$6$saltremoved$hashremoved',
}
}
}
}
It was also my intention to start with a "wanted.txt" file, listing the things that should be done once, but that, for this learning purpose, is being achieved by the "if" statement, while the "unless" statement would have to be expanded to handle the two conditions. I'm trying to solve my problems one at a time, so the "wanted" file can wait. The suggestion that I may have misnamed the facts is probably correct, as I am unclear about the difference(s).
↧