-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Issue-96 Add AIX Support #97
Conversation
Hi @TJM, thanks for the PR. You can click on the travis link, it will show you all issues that the testsuite found. |
Will fix stuff tomorrow, thanks |
Hi there, I think I may need some rspec help. https://travis-ci.org/voxpupuli/puppet-autofs/jobs/345296736 I know why this test is failing, because I added the "correct" filename for /etc/auto_master on Solaris. This brings up two issues for me.
I am researching, but any pointers in the right direction are appreciated ;) |
That was kinda painful... sorry about all the noise. It is still not testing AIX. I am not sure why, as I think I updated metadata.json correctly (its lint is not balking). I am guessing its just soo obscure that its not in the factdb. I have done some testing on live systems and I think its good. |
I haven't digged through the travis output, but I think it emulates facter 2.5 or 2.4. Facts come from https://github.com/camptocamp/facterdb/tree/master/facts/2.5. Do you have access to an AIX box and can provide those facts? The procedure is described in the README.md |
@@ -0,0 +1,9 @@ | |||
version: 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hiera 5 \o/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I just couldn't bring myself to do the params.pp thing. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's totally fine.
Variant[String, Array[String]] $package_name, | ||
Optional[String] $package_source, | ||
Enum[ 'stopped', 'running' ] $service_ensure, | ||
Boolean $service_enable, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more datatypes \o/
# @param service_name Determine the name of the service for cross platform compatibility | ||
# @param auto_master_map Filename of the auto.master map for cross platform compatiblity | ||
# @param map_file_owner owner of the automount map files for cross platform compatiblity | ||
# @param map_file_group group of the automount map files for cross platform compatiblity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
puppet-strings \o/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aye, I did not generate the docs, I assume that is part of the release process?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strings generation are a part of the release process, yes
manifests/service.pp
Outdated
|
||
exec { 'automount': | ||
path => '/sbin:/usr/sbin', | ||
command => 'automount -v', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this do? Is this always needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tells the automount (daemon) to reload its config, without restarting (which causes automount to attempt to unmount all of its mounted filesystems).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we do a notify to the service? CC: @dhollinger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puppet seems pretty intent on restarting it on AIX at least, potentially other OS's as well, it doesn't seem to handle the concept of a "soft" reload.
On AIX It makes a decision on whether to send it a "signal" (HUP?) based on lsssrc -Ss automountd
output. Basically the 11th(?) flag is a -S vs a -K, see provider for gory details. Long story short, its out of our hands. The src provider (used by AIX) seems to ignore the "restart" command offered as a parameter to the service resource as well, we tried that. :)
I would bet based on "POSIX compliance" type reasoning that it also works for Linux, but I have not tested. (see my reply, this does not work in Linux)
On a side note, I talked about this in #puppet on Puppet Community Slack, and someone else (Richard Lawson) had to come up with a similar workaround.
I did not get a chance to test on Solaris, but from what I recall that is also the correct way to "notify" automount to refresh its auto_master file.
This is ugly, but the best thing I could come up with that actually works without restarting the daemon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CRAP: I just tested on Linux and because there is not an "automountd" it thinks you are trying to start the daemon again. Obviously this won't work as is... let me think on it and get back to you.
FWIW, Linux suffers the same problem. It uses "restart" (which is a stop and start) vs a "reload" (which is a HUP)
- CentOS 6
Info: Concat[/etc/auto.master]: Scheduling refresh of Service[autofs]
Debug: Executing: '/sbin/service autofs status'
Debug: Executing: '/sbin/chkconfig autofs'
Debug: Executing: '/sbin/service autofs status'
Debug: Executing: '/sbin/service autofs restart'
Notice: /Stage[main]/Autofs::Service/Service[autofs]: Triggered 'refresh' from 1 event
- CentOS 7
Info: Concat[/etc/auto.master]: Scheduling refresh of Service[autofs]
Debug: Executing: '/bin/systemctl is-active autofs'
Debug: Executing: '/bin/systemctl is-enabled autofs'
Debug: Executing: '/bin/systemctl is-active autofs'
Debug: Executing: '/bin/systemctl restart autofs'
Notice: /Stage[main]/Autofs::Service/Service[autofs]: Triggered 'refresh' from 1 event
Looks like I am going to have to have a @param reload_command
, but making that work will probably require %{facts.os.release.major}
unless I play real fast and loose with something like pkill -HUP automount
:)
spec/defines/mount_spec.rb
Outdated
@@ -29,7 +43,7 @@ | |||
is_expected.to contain_concat('/etc/auto.home').with( | |||
'ensure' => 'present', | |||
'owner' => 'root', | |||
'group' => 'root', | |||
'group' => group.to_s, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the .to_s isn't needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure, I wouldn't think so, given that I assigned it as 'groupname', but I "borrowed" that idea from the puppetlabs-ntp spec tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you remove it and test if it works? IMO that isn't needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it works without the .to_s
RE: AIX Facts.... Their readme also says it "supports" AIX, perhaps it used to? I will have to copy the puppet facts output over and "sanitize" it a bit, but I will send them a PR next week. |
manifests/init.pp
Outdated
String $auto_master_map, | ||
String $map_file_owner, | ||
String $map_file_group, | ||
String $reload_command, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TJM Is the plan here to supersede the Service resource in the resource abstraction layer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, see below
manifests/map.pp
Outdated
@@ -38,14 +38,15 @@ | |||
|
|||
unless $::autofs::package_ensure == 'absent' { | |||
Concat { | |||
notify => Service['autofs'], | |||
before => Service[$autofs::service_name], | |||
notify => Exec['automount-reload'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an AIX/Solaris requirement only or is it global to autofs?
If so, would it be better to build this into a native type/provider? (I'm not a fan of Exec
, I've had too many issues with them not working or executing when they shouldn't)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is global to autofs. If you use the puppet "service" resource, the "notify" will restart (stop then start) automount(d). This causes automount to attempt to unmount all automounted filesystems for a simple configuration change, which is not desirable. The EL6 init script and EL7 systemd svc have a reload
option which send a HUP to the automount PID to tell automount to re-read its auto.master map without completely restarting.
I tried to use the restart
command parameter, but the AIX service provider (src) completely ignores it, and just runs a stop/start operation anyhow (see my previous comments about lssrc). I think the best thing would be https://tickets.puppetlabs.com/browse/PUP-1054 .. but until then, a refreshonly exec was the best workaround I could think of. The type/provider mechanism would be a more proper/permanent fix, but I don't really know enough ruby to go down that path. It does occur to me that you might be able to "sub-class" (?) the service provider and just provide the reload capability, but if you go to that much trouble, it should probably be its own module? (or a PR to PUP-1054)
Unfortunately I already combined my commits, or you could cherrypick around it ... I guess I could split the "better reload" capability off to a different branch as it is technically NOT related to AIX.
Admittedly, using pkill
was just a shot from the hip, as per my previous comments. While it worked in my test systems, it did not pass tests, likely due to the lack of pkill
in the most minimal builds.
~tommy
I'm fine with this, thanks for the work @TJM. @dhollinger can you review as well? |
autofs::maps: {} | ||
autofs::package_ensure: installed | ||
autofs::package_name: autofs | ||
autofs::package_source: null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is null
correct? I thought ~
was used for setting undef
via hiera.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null works correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for confirming. I struggled to find a definitive answer on any difference between using null
or ~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see this while reviewing, thanks for catching this @alexjfisher. Should we switch to ~ here? As far as I know, ~ is the best practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're equivalent: http://www.yaml.org/refcard.html
(Or you can nerd out and read the spec itself!)
@TJM can you please rebase? |
meh, now there are failing tests, I will |
Do you need anything else from me on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Though I want one more set of eyes on it as well.
@alexjfisher or @bastelfreak can you take a second look, make sure I didn't miss anything?
This fixes Issue-96, providing AIX support. NOTE that we enabled module level hiera to provide OSFAMILY specific data. We also put in a basic workaround for the "reload" of automount. Currently, at least on AIX, the service provider ignores the custom
restart
command.NOTE: I did my best on the tests. I was not able to use PDK to validate the tests because your gemfile has binary requirements, which I cannot compile on my "work" computer. Let me know if they need fixed.
Thanks in advance,
Tommy