r/sysadmin • u/danielkraj • Nov 28 '20
Is scripting (bash/python/powershell) being frowned upon in these days of "configuration management automation" (puppet/ansible etc.)?
How in your environment is "classical" scripting perceived these days? Would you allow a non-admin "superuser" to script some parts of their workflows? Are there any hard limits on what can and cannot be scripted? Or is scripting being decisively phased out?
Configuration automation has gone a long way with tools like puppet or ansible, but if some "superuser" needed to create a couple of python scripts on their Windows desktops, for example to create links each time they create a folder would it allowed to run? No security or some other unexpected issues?
20
u/swampdrainr Nov 28 '20
I don’t understand. Why would you not allow a user to create a script they need to do their job better?
2
u/danielkraj Nov 28 '20
I wouldn't have been surprised if there was some "no-user-scripting" rule, but... I'm glad there isn't then.
2
Nov 28 '20
At my work all servers and laptops are managed with chef. Users are encouraged to write chef changes for their laptops, but that's a bar that they aren't expected to meet, so we also have friendlier software that users run which then informs chef to do certain actions.
But for those who want to, they can write chef changes. Those changes just need to be code reviewed.
18
u/Komnos Restitutor Orbis Nov 28 '20
Some orgs lock things down tighter than others. I once had to explain to a (very new) security analyst why he couldn't just blanket disable PowerShell across our entire organization. "But it can be used maliciously!" Yeah...
17
u/ObscureCulturalMeme Nov 28 '20
"People can also use the pointy end of a screwdriver to stab yer fuckin' eye out, but good luck getting any work done if you take all their screwdrivers away..."
10
u/survivalmachine Sysadmin Nov 28 '20
This is such a blanket excuse that so many inexperienced “security” people use. All I hear is “I don’t know how to manage it and I am too lazy or stubborn to learn, therefore it’s a security risk”.
9
u/gordonv Nov 28 '20
New Sec Guy: "I don't know what this does, so it must be a threat."
12 year old: "You deleted DLLs? Come on man, even I know they are part of software."4
1
Nov 28 '20
It took me years to convince management that PowerShell was no more harmful than anything else. People fear what they don't know...
1
u/chuck_cranston Nov 29 '20
Ugh...
I got this exact email from the guy that runs the net sec shop when he heard we were starting to really use some powershell scripts for fairly simple tasks.
And our guy isn't new, just incompetent.
6
u/gordonv Nov 28 '20
ITT: Will scripting survive?
Meanwhile...
COBOL is stronger than ever in the financial industry.
Many college fax lines and fire department alarms require analog POTS lines on century old infrastructure.
Radio is being privatized.
Kids are using 15 year old books in schools.
The United States can't figure out how to set up a voting system for Federal and Local elections.
Everyone has a mobile computer in their pocket, but we still have automated telephone prompts and are put on hold by machines.
I can order almost anything on Amazon, but no help understanding government paperwork or paying off a bill immediately with money I have ready on debit or credit.
1
u/danielkraj Nov 28 '20
yes that... that puts things in perspective. although tom Scott covered (pretty well?) electronic voting and the reason why it still may be a bad idea.
3
u/gordonv Nov 28 '20
It's odd though. People can do all the great things we've been able to transmutate to paper over the Internet, including voting.
I feel if someone can wire money, why not wire a vote? Why can't we secure the vote like we secure money? I'd argue money is more important.
0
Nov 28 '20
[deleted]
2
u/gordonv Nov 28 '20
:)
People freak out over votes, but don't realize we're already doing that with money and health records.
I think it's awesome that the general public declared that Social Security numbers will be the common ID key. Someone was like, enough of the BS. This organization did all the work, lets just piggyback off that.
We should be doing that for everything.
392
u/guemi IT Manager & DevOps Monkey Nov 28 '20
Scripting and configuration management are tools to do different tasks. So I don't see what either has to do with the other.
205
u/robvas Jack of All Trades Nov 28 '20
Visit the powershell sub sometimes. People try to re-invent the wheel every day :(
249
u/SenTedStevens Nov 28 '20
The more hilarious ones involve questions like, "We have a bunch of domain joined computers. How can I map drives/printers in PowerShell?"
GPOs have been around for a long time. Use that.
192
Nov 28 '20
"I tried to use GPO to do it, but it didn't work. Now I tell everyone that GPO is flaky and unreliable because I made assumptions about how it works, and when it didn't work that way, I gave up instead of figuring out why"
I've met people with over a decade of windows experience like this. The most common error? Adding computers to a group, adding that group to a GPO, then rage quitting when the GPO didn't get applied to the computers.
34
u/Ssakaa Nov 28 '20
Could be worse, I've known people that think RAID is evil because they once had an issue where they couldn't recover a failed array... that they had no backups on... and after that refused to use it out of the assumption that they could recover from individual disks more reliably if one failed...
They did at least start making backups...
17
u/BrFrancis Nov 28 '20
Why is raid 0 a level? If raid is "redundant array of i-word disks" ... How is there a level of raid that isn't redundant.
What's really evil, is accessing files on network shares using iscsi so you can device mapper them into a raid 10 configuration and present that to a VM. Muahahahahhaha
10
u/Ssakaa Nov 28 '20
I mean, at that point, the word redundant is redundant, isn't it?
Redundant (adj): not or no longer needed or useful; superfluous.
And, the data itself must be superfluous, if someone's going to put it at that much excessive risk, so it sorta fits that the word stays...
4
u/corsicanguppy DevOps Zealot Nov 28 '20
Seems the 0 is part of it.
If I have 0 apples, why even say the apple part?
10
5
u/catonic Malicious Compliance Officer, SL-Eh Manager, BSFM Nov 28 '20
It's RAID0 in the computer counting from zero sense, and RAID1 is actual RAID in the human counting sense. It's almost an inside joke for the 10 types of people in this world, those who speak binary and those who don't.
RAID0 isn't RAID but it's there because the drivers at the time were speed, speed, and speed or reliability (good, fast, cheap; pick two). RAID started appearing before video capture cards had integrated JPEG processors and video capture as well as other high-performance applications required high and consistent bandwidth.
Silicon Graphics Inc. (SGI)'s emphasis was speed and performance, and over time folks realized it was at the cost of security and stability. Still, they absolutely led the front on performance for the computers of the generation and had software OpenGL before others. Intergraph however implemented a full OpenGL reference implementation, which is why John Carmack had a luggable built with an Intergraph Wildcat 4000 in it (which itself had an amount of RAM equal to many computers of the day: 128MB).
→ More replies (2)5
u/StabbyPants Nov 28 '20
Why is raid 0 a level?
mathematical completeness? also, it's a minor tweak to raid 5 that improves performance and fits a use case (all data is recoverable), but you have to understand how it works
97
u/jews4beer Sysadmin turned devops turned dev Nov 28 '20
The "I can't figure out how it works therefore it sucks and is an unreliable tool" is a mindset that is pervasive across the entire IT industry.
→ More replies (1)28
u/CraigAT Nov 28 '20
True. But this also highlights the inability of IT companies to make products that work as users expect.
20
u/skat_in_the_hat Nov 28 '20
Sometimes you have to break the assumed mindset for something to work better. Look at the refusal to use SELinux by admins.
14
u/CraigAT Nov 28 '20
Agreed. The customer is not always right, but sometimes neither is the developer.
14
6
u/Paraxic Nov 28 '20
NGL selinux is a pita, probably does a good job at what it's supposed to do but the tools for it are tedious to say the least.
→ More replies (3)→ More replies (3)2
u/CraigAT Nov 30 '20
I'll add in NTFS permissions! I understand how they work and can do whatever I need to do, but often when you have specific requirements it is not always intuitive how you would achieve that.
2
u/StabbyPants Nov 28 '20
why would they ever do that? 'read my mind' is a bit of a losing strategy, and GPOs are in a domain where intuition doesn't quite cut it
5
u/Inaspectuss Custom Nov 28 '20
To be fair, GP can be really frustrating to deal with at times, especially preferences. That said, when you have it set properly, it’s bulletproof.
The type of person you’re talking about is the same kind to dump everything in Default Domain Policy. People see GUI and think “oh, I can just click through it and read descriptions”. Nope. You need to learn it inside and out.
4
4
u/figuresys Nov 28 '20
"I tried to use GPO to do it, but it didn't work. Now I tell everyone that GPO is flaky and unreliable because I made assumptions about how it works, and when it didn't work that way, I gave up instead of figuring out why"
You've got this SO on-point, except it's for EVERYTHING. My God, people just don't try to stretch their brains and then just give up and declare that thing bad.
4
u/korewarp Nov 29 '20
Because most people in my age group are used to some kind of fucking feedback from the software we use. It's not our fault that you create a GPO, add users/computers to it and then it just.. sits there. You run gpupdate on a few PCs and the GPO gets applied to.. some of them? Where's the fucking consistency. At least running a PS script does what you fucking expect it to.
I'm not saying GPOs are bad at all, GPOs have their uses and are a strong and powerful tool for any windows sysadmin. But I can definitely understand why certain 'immediate change' use cases require PS for consistent results.
3
Nov 28 '20
I’ve been on both sides of this coin. Either they work great or I’m too much of a dolt to figure it out.
Then there was the time GPO printer management worked great, until one day it decided to flake out. I think I just removed and recreated the policy from scratch, but it’s massively annoying when GPOs just stop working.
2
u/spyingwind I am better than a hub because I has a table. Nov 28 '20
What I've found is that if GPO is setup correctly, usually rebooting the machine affected 3-4 times fixes the problem, else you setup the GPO incorrectly.
5
u/ghjm Nov 28 '20
What you need to do is run gpupdate /force seven times, reboot into safe mode, run gpupdate /force three more times, then reboot again. Or at least, that's what the deskside support techs always tell me do, and I assume they know what they're doing.
3
u/snb IAMA plugin AMA Nov 29 '20
Do I sacrifice the goat before or after rebooting into safe mode?
2
u/HTKsos Nov 29 '20
Durring, the blood needs to be dropped from the still beating heart on the F8 key at the presise moment in the boot sequence. Fastboot and SSD's did in the herd.
2
Nov 28 '20
I’m a newly minted SysAdmin and I’m really glad I came across your comment before I was convinced otherwise.
1
Nov 28 '20
Well, explain to me how it's reliable when a constantly running GP powershell login script gives us a black screen after UAC prompts (that are only solved by logging off/logging back on) whereas that same script added to an AD profile gives us no issues.
I had to resort to rewriting the script into something that worked with CMD instead, since we're moving away from AD scripts.
1
1
u/cryptsyryus Nov 28 '20
This right here! Slayed me. I can relate, as I once was one of the “assumed”.. the. I decided to dig in.
1
1
u/zrad603 Nov 30 '20
I used to always setup printers via GPO. Then we finally got rid of some shitty legacy system we had at work, but it required replacing almost every printer in the entire company. (weird lease agreement thing where we leased the printers from the legacy system company, long story)
So I setup the new printers with GPO options, and it just did not freaking work. Turns out it was weird driver issue.
I wrote a powershell script that would install the print drivers if necessary, and map the network printer. Had GPO run it as a startup script. No "print server" necessary to get the print drivers from. Just had a network share with the print drivers. Worked so much more reliably, I'm never going back to configuring printers the old GPO way.
The only problem is the powershell script I wrote only worked with Windows 10. There is a possible workaround to make it work with Windows 7, but we had so few Windows 7 machines left at that point I just configured those manually.
1
0
Nov 28 '20
[deleted]
4
Nov 28 '20
100% of them relate to terrible printer drivers
That is not entirely true, sometimes it is also terrible printer hardware, terrible (lack of) standards in printers, terrible printer firmware,...
0
Nov 28 '20
[deleted]
1
u/HTKsos Nov 29 '20
14 years agooo... Winders 2003.. no. Preferences came in 2008 IIRC. But they are as confusing as C.R.U.D. I replaced a few scripts with GPOs for mappings
17
Nov 28 '20
[removed] — view removed comment
34
u/Yescek Nov 28 '20
That comment is a bit of a "gotcha". That example doesn't really have enough detail to really get into the specific fix.
Possible solution would be to create an OU specifically for the subset of computers you're trying to apply the GPO to, then link the GPO to said OU.
Would need to make sure your new OU isn't inheriting any GPOs that could potentially conflict though.
15
u/Resolute002 Nov 28 '20
Also for some GPOs they don't take full effect until after restarts. In this era of largely remote work with the pandemic this surprises people all the time.
10
u/StatefulDecay Nov 28 '20
Especially when adding computers to security groups. The PC only checks for what it is a member of at restarts.
18
u/Resolute002 Nov 28 '20
When you add in this pandemic, and computers restarting off site... all of a sudden doing it by PowerShell doesn't seem so stupid.
→ More replies (1)6
u/Smartguy5000 Sysadmin Nov 28 '20
This will allow you to pull updated membership on a comp account sans restart. https://www.normanbauer.com/2016/03/30/how-to-purge-kerberos-tickets-of-the-system-account/
→ More replies (6)17
u/Komnos Restitutor Orbis Nov 28 '20
Applying the GPO to whatever OU(s) the computers are in. Applying a GPO to a group is just a filter; it still won't apply to anything outside of the locations it's been linked to, even if they're members of the filtered group.
11
u/jpmoney Burned out Grey Beard Nov 28 '20
A powershell script, obviously.
3
u/NoncarbonatedClack Nov 28 '20
That they'll then post to r/PowerShell a giant blob of stuff with no code blocks.
4
u/thatpaulbloke Cloud Engineer UK Nov 28 '20
Assuming that the OU containing the computers is linked to the GPO (or one below it with inheritance) the reason that it isn't applying is the same as when you add a user to a group and they don't immediately get permissions etc - the Kerberos ticket needs to contain the group which it will only do on log on to AD. Just like with a user you can get the computer to log off and back on to AD (i.e. reboot it) or you can drop the Kerberos ticket by running
klist -li 0x3e7 purge. Or you can wait - the ticket will expire in time and the membership will update.47
u/da_chicken Systems Analyst Nov 28 '20
I can excuse those. They're almost always places where the institution has no fucking idea what sysadmins actually need to do their job or that are terrified of things like domains. It's always someone trying to manage a network with a boss who doesn't know their ass from a hole in the ground.
The ones that irritate me start with, "I have this GUI that I wrote in Powershell...". Really? Look, just because it's a general purpose scripting language doesn't mean that you should publish an application written with it. C# is pretty easy!
Or the ones that call
Read-Host. You know that parameters are there for a reason, right?13
u/SenTedStevens Nov 28 '20 edited Nov 28 '20
In my first Junior Sys Admin role after I got promoted from help desk, GPOs were the first thing I started implementing. Initially, users got .bat or .vbs logon scripts that mapped resources but they weren't very reliable. We got too many calls from people saying their "L:" drive didn't map and logging out/back in fixed it. With a couple GPOs, that issue practically went away.
I agree with you how some people make fancy GUIs for things.
21
u/tossme68 Nov 28 '20
I love to make fancy GUIs from my scripts, it's not really for my benefit but when I've created a scriptlette with a nice GUI I distribute it to my co-workers. Some are smarter than others but in general I've found that if I add a gui they use the script and if I don't have a GUI they don't use it.
4
u/TopCheddar27 Nov 28 '20
I did the same thing when I got hired at my current place. Now it's the same call except I tell them to hit the little arrow next to my PC to expand their network drives list... fml
2
u/BergerLangevin Nov 28 '20
I did make some Gui and it was to give task to someone not in IT. I was able to abstract most of the task.
Last time I did one to scroll object returned by an API because I needed some object id.
I did a dashboard with it that was much faster to load than what the official Website is providing.
3
u/BergerLangevin Nov 28 '20
PowerShell provide some tools and inner automation which make coding simple thing faster. In c#, this would require a lot of bell and whistles to achieve the same thing.
3
3
u/redvelvet92 Nov 28 '20
To be fair that is just people with lack of experience asking questions. I remember 4 years ago I was trying to do the exact same thing. I had no idea how web apps were actually created, so in my head I wanted to make a GUI with Powershell.
With more experience I have now, I know certain tools exist for certain jobs. Use them.
2
u/Ssakaa Nov 28 '20
The benefit to powershell over C# for quick and relatively simple GUIs (i.e. not overblown applications trying to compete with general use cases like Word/Excel/etc) is that it's only dependent on pre-existing in-OS tools, not an added development environment to go from source to running tool, particularly when other users may need to modify it to suit their own environments.
3
u/nostril_spiders Nov 28 '20
Amen; I tell them that every chance I can, but I'm only one person.
What can men do in the face of such reckless not-invented-here?
0
Nov 28 '20
[deleted]
7
Nov 28 '20
C# is kind of the de facto development language in a Windows environment, especially for GUI development. It's almost trivial to set up a GUI app using it. With the availability of Visual Studio Community and VScode, it's a really attractive option. Plus, most client Windows machines usually have either .NET Framework 3.5 or 4.6.x/4.7 installed already.
0
11
u/Noobmode virus.swf Nov 28 '20
So how do you handle GPO in a cloud environment where MS has basically said GPO is legacy? Like an honest question. Is there config state/mgmt in Intune?
1
Nov 28 '20
GPO's are terrible because group membership is terrible so RBAC and applying policies using groups is terrible, automation is impossible, and theres nothing monitoring the state of policies applied.
So Saltstack or Ansible/AWX are what you'd want to use generally.
5
u/spyingwind I am better than a hub because I has a table. Nov 28 '20
Or when you want to enable SSL certs for WinRM. When you still have 2008/R2 with PS 2.0 in your environment you can't run elevated commands to enable SSL. GPO doesn't fix this. GPO wouldn't fix this as we have well over 1000 different domains. A config manager would do wonders, but then we would need to setup a GPO on 1000's of domains.
So in the end, either a script or a CM tool would work just fine, but configuring 1000's of domains is no fun task.
1
u/blissed_off Nov 28 '20
Definitely a use case for GPOs. I still had to write a Powershell for drive mapping when all of my office became remote with Covid, since the computers weren’t picking up on the GPO for drive mapping all the time. It mostly works.
7
u/TMSXL Nov 28 '20
Off topic, but GPO should still work remotely.....persistent mapped drives setting is the key.
2
u/blissed_off Nov 28 '20
Like I said, it usually does work. Just sometimes it either doesn’t, or doesn’t kick in fast enough for some users patience. That’s where the script comes in.
→ More replies (30)-1
u/Resolute002 Nov 28 '20
There's nothing wrong with using powershell to do it.
This thread is full of guys who have apparently never worked a place like mine, where the guy doing GPOs considers it beneath him to do something like map a drive to a subset of machines.
Also GPOs are going to go away in the future and Intune and Azure will replace them, with much better control and reliability. In that space Powershell is still supported and used to great effect.
My overall point here is some people are avoiding GPO because it's dated, or because it's simply not an effective option for them.
0
Nov 28 '20
[deleted]
→ More replies (1)1
Nov 28 '20
Well GPO's at least allow you to audit whats going on so its far better than Powershell, but its far less useful than modern configuration management tools since the state cant be monitored after they are applied. That and group membership doesnt refresh on servers or logged in users, making it pretty crappy for dynamic configurations.
12
u/jantari Nov 28 '20
Not true the powershell subreddit is:
50% "guys I'm having trouble with this if-statement"
50% "I got my first script to work today (it copies a file btw!) feels great to be a PowerShell admin! :)"
2
u/hellphish Nov 30 '20
Don't forget the "I wrote this 7,000 line script and thought I'd share it with you guys. It controls my coffee maker"
1
u/jantari Nov 30 '20
imo that's a hundred times more interesting than scrolling through 10 pages of the same "I found these two commands that give me errors, but I didn't read the error message, pls do my job for me guys"
3
u/ALombardi Sr. Sysadmin Nov 28 '20
They do. I've been using self-made scripts for things that other tools can't give or I may not need it for all its purposes, just one. Like before patching weekend, running a PS script to check uptime against our servers. I run it again after. Some of our servers auto-reboot after patching and some we do manually. If a server still has a long uptime, I use it to find out why the hell it didn't reboot.
0
u/robvas Jack of All Trades Nov 28 '20
Use an RMM tool. Does that and much more.
1
u/ALombardi Sr. Sysadmin Nov 28 '20
Yeah, but when I now have a script I can run against all servers within our Server OU, specific OUs, etc., and if looking to generate a report on anything that would response with a PS value*,* I have it. Nicely formatted, emailed to whoever I un-comment in the script.
Not only is it flexible, but I had to create it, all the while it keeps me fresh on PS for certain things.
Way better than any RMM tool to make it easy.
1
u/robvas Jack of All Trades Nov 28 '20
My tool (Kaseya) lets me choose whether I want the servers to reboot after patching. I can view them by uptime, see what patches are applied to what servers, blacklist a patch, I get an email telling me which patches failed to apply... my servers and workstations are all in groups etc
I can appreciate creating studs but this stuff has already been made, is tested blah blah. I just want to patch my servers and get my maintenance window over with, not tweak and hack.
→ More replies (2)4
u/gordonv Nov 28 '20
You mean make a better wheel?
Why does Chef, Ansible, Puppet, Terraform, cloudformation, SDKs, CLIs, and a web console exist for the same job?
The answer is because each is tailored to a certain situation. It's not one size fits all. People are fighting the "When you're only tool is a hammer, everything looks like a nail" mentality.
1
u/el_darbo Nov 29 '20
Hey it's not my fault my professors have me reinvent the wheel to make crappy little scripts! I'm just doing it for the grade, man.
1
u/defmain Nov 29 '20
My last company re-invented the wheel. Mostly pet projects let run out of control. The end result was I had to use Powershell to make DNS changes but there was a global lock so you would have to wait for someone else in the company to finish making their "A" record before you could make yours.
→ More replies (10)1
25
u/gordonv Nov 28 '20 edited Nov 28 '20
The tools used for configuration management are higher level abstractions of scripting configs. Config Management Software is merely the deduplication and simplification of scripts.
I'm not down talking config management software. In fact, it's great we can have a unified view and that many people can understand a simplified view of a complex setup. But it sucks that oversimplified software does not touch every need.
Like "systemd" in Ubuntu. It takes a lot of complex tasks and makes them easily identifiable, completable, and hard to screw up.
0
u/Ssakaa Nov 28 '20
Like "systemd" in Ubuntu. It takes a lot of complex tasks and makes them easily identifiable, completable, and hard to screw up.
And does quite a few other, unrelated, things in arguably questionable ways that made a lot of people very angry. It also made a number of use cases impossible now, compared to what came before.
And... those tasks that it performs were easily identifiable, completable, and hard to screw up for anyone that knew anything about the init script system at play at the time, on the distro they were using. The one thing systemd has done is manage to market itself to distros well enough that it became the common, used almost everywhere, tool for that job, rather than any of the competitors being ubiquitous. That allows someone used to any other systemd-using distro to jump to any other and be on very familiar ground... while still having to sort out the particular oddities of service naming et. al. that varies between each.
3
u/gordonv Nov 28 '20 edited Nov 28 '20
I see what you're saying. SystemD indeed is a hammer, and it has made a lot of problems look like nails. We've lost flexibility. And anyone that deviates from the SystemD standard is down talked.
Conforming and cleaning up things will piss of people. I'm sure somewhere in a log cabin, some guy is angry Windows is the dominating OS for desktops, not some obscure RISC OS.
4
u/Ssakaa Nov 28 '20
Yeah. But, again, I give credit where credit's due. I may not like the sum total of the results of unification (one might consider my coat a bit of a brown color in that respect), but I can at least see what they were trying to accomplish, and they at least managed to standardize something. The world was a lot more variable before that...
-2
u/system-user Nov 28 '20
yep, and the author got a bunch of death threats when it was released into RHEL as the new standard. systemd is "ok", but it's not superior to what it replaced. I'll take BSD's method over any of the newish linux implementations any day, that's some solid code.
The big issue with systemd is that it required a massive undertaking to change over an entire org's chef/puppet/ansible/etc implementation to manage services using a new method with different commands. It created a lot of unnecessary work for thousands of already overworked people with minimal to zero benefit.
The reinvented wheel is out of control in the linux community and it reeks of a combination of ignorance and false sense of superiority from young engineers looking for attention in their resume. I can't think of a single thing that linux does better than BSD from a low level OS standpoint, but plenty of things that it does worse. Maybe I'm just getting old but kids these days need to brush up on their history before blasting out some new version of core components just for the sake of newness.
5
u/boomertsfx Nov 28 '20
I’m so glad init scripts are mostly gone. It was a huge mess and every service did things differently and often wrong. Nope, don’t miss it at all! I remember hating it because it was different that what I knew up until then, but imho it’s superior once you grok it. I’d really like to know what people miss from sysv init.
Side note.... It seems Solaris was ahead of its time with zones, zfs, and their service framework
2
u/Delta-9- Nov 29 '20
I'm inclined to agree. I admit I'm a young and naive Linux admin, having "grown up" with systemd...
But, having to go through init scripts that can differ on every distro to understand how exactly they're starting daemons is a lot less convenient than reading the man page or running
systemctl cat. Oh, and that's after I figure out which /etc/rc.* directory it's in, which (in Ubuntu 14 and el6's case) comes after determining if I'm looking for an init script or an Upstart file.I get the "it's not unixy" animosity, but I'm pretty convinced that most systemd hate is just for the sake of hating something. The editor war is over (vim won), so all the nerds with no lives have to now argue about init systems.
2
u/system-user Nov 30 '20
yep, solaris was king for quite a while in those regards. freebsd has picked up the same features now (for a while) and is a pleasure to use if you're looking for an alternative... and it includes OpenSolaris extensions as well as a Linux binary compatibility layer.
1
u/gordonv Nov 29 '20
The thing is, init scripts were part of the in between where I needed to bootstap a GUI like LXDE to auto start and only start a program I needed.
Something I feel should be a common task, but isn't.
6
u/wuwei2626 Nov 28 '20 edited Nov 29 '20
I dont understand how this comment is so upvoted. You are not correct. Configuration management is not a "tool", it is a process that can be handled by any number of "tools". Almost all of those config management tools started as a collection of scripts in a somewhat pretty wrapper. The fact that so many seem to agree that config management is a tool scares me and indicates there are a lot of admins that know how to use a specific set of tools, not really understanding why.
One of those ignorant admins down voted without a reply. Performing an action without being able to articulate why; kinda proves the point...
2
u/gordonv Nov 29 '20
it is a process that can be handled by any number of "tools".
That's a business sided definition. It's not wrong, but it's too vague in my opinion. It would be like me insisting a crow is not an animal or a corvid, but a bird. That is not wrong. Neither are those other definitions.
1
u/badtux99 Nov 29 '20
I have configuration management install system management scripts e.g. a script in /etc/cron.hourly to clean out a particular log directory that tends to overflow (all our logs are replicated in our central logging server anyhow, so). So the two are not completely disparate. But scripts are payload, not configuration.
→ More replies (5)0
u/Gregorio246 Nov 28 '20
Answers like this are so useless...
In many cases, a scripting solution can directly replace a more formalized configuration management solution. OP is asking how acceptable that is within the industry.
1
u/guemi IT Manager & DevOps Monkey Nov 28 '20
No, OP is asking whether or not his 15 bash scripts to configure his Linux server is OK or not.
115
u/lynnuks Linux Admin Nov 28 '20
Scripting is elegant and cheap option to achieve automation for everyone in almost every case. And ansible is written in python, so scripting will survive.
45
u/tossme68 Nov 28 '20
AWS has a BASH shell, Cisco uses Python and BASH. Scripting is going nowhere.
8
u/samehaircutfucks DevOps Nov 28 '20
Are you referring to EC2 specifically? Cuz that statement about AWS is very misleading. AWSCLI is how you make api calls to the platform, not BASH.
5
u/guterz Nov 28 '20
Maybe he’s talking about userdata where you can invoke a shell upon startup? Not sure though.
3
u/samehaircutfucks DevOps Nov 28 '20
yeah I figured as much; just don't want people to equate AWS and EC2, there is so much more available than just virtual servers in AWS :)
1
u/tossme68 Nov 29 '20
I was actually referring to CodeBuild -sorry I didn't specif, AWS has so much stuff it's hard to keep track of them all.
1
3
1
49
u/LittleSeneca Security Admin (Infrastructure) Nov 28 '20
They aren't mutually exclusive. They are mutually inclusive. I use Chef to push ruby code to end points which applies a specific set of instructions to the end point. I need to know ruby scripting to create a functional code push. I need to know Chef to push the code at scale.
4
47
u/black797 Nov 28 '20
Half of our config mgmt is running a ps script in a container on a schedule...
11
u/keftes Nov 28 '20
Config management is slowly dying in favor of immutable infrastructure. Scripting will always be around.
6
Nov 28 '20
immutable infrastructure
What buzzword is this? I need to duckduckgo this.
6
u/keftes Nov 28 '20
Hardly a buzzword these days. Here you go: https://www.hashicorp.com/resources/what-is-mutable-vs-immutable-infrastructure
3
u/dabasset Nov 29 '20
Great read! Thanks for the share. This is a huge reason why cloud computing is the future. I wasn’t aware of the buzzword but I was aware of the practice.
1
u/poi88 Nov 30 '20
Thanks for the pointer!
Very useful, and as the other user mentioned one was certainly familiar with the context and concepts behind it but it's great to know that it has a name and more developed thoughts for it.
17
u/the_most_interesting Nov 28 '20
I don’t think it is frowned upon at all. There is the right tool for every occasion . If you need to get something simple done on a server and it would just require a few lines of bash, why not just use bash? If you are trying to configure an application or install a service on hundreds or thousands of endpoints, than of course a configuration management solution will probably be your best choice. But even configuration management tools have their limitations, that’s why some of them allow you to build your own custom modules or you can have the configuration management tool trigger a custom script . For example Ansible allows you to build custom modules using Python. Like I said each tool has its use. I think a more valid statement is that automation is the way forward regardless of what method or tool is used to achieve this.
7
u/necheffa sysadmin turn'd software engineer Nov 28 '20
Would you allow a non-admin "superuser" to script some parts of their workflows?
Yes. Sites that actively make it harder for people to improve their quality of life through automation are asinine. Absolutely asinine. It also displays an utter lack of understanding on how security in the machine works.
If you are not going to allow automation you might as well just get rid of the computers, the network, and hang your hat up, everyone will go back to pen and paper.
7
u/rankinrez Nov 28 '20
It’s all scripting. It’s all programming.
Sure though use the Ansible modules not your own hacked together scripts. Someone else built them and spent more time on error checking etc so why not.
5
u/SevaraB Sr. Engineer (N+, CCNA) Nov 28 '20
Configuration management is an API. Scripting is for automating those tasks and functions that aren't included in an API and where the API cannot (at least not feasibly) be extended.
4
u/atroxes Electrical Equipment Manager Nov 28 '20
That's like asking "Is using a saw being frowned upon in these days of "automatic turning tablesaws"?
4
u/lotekness Nov 28 '20
It's all still relevant. Even batch and vbscript in windows.
Honestly, the question isn't really so much what's frowned upon as what's available to you and what works.
Knowing how to script intelligently translates through most languages, so don't sweat other people's opinions on the matter unless they're willing to "do it right" for you. Don't be a magpie. Make sound choices on what works in your environment unless there's a damn good reason for it long term.
6
u/MiataCory Nov 28 '20
I'm comfortable giving users scripting abilities on a case by case basis, with the understanding that if they screw something up, it's on them. If your script deletes a bunch of folders from the shared drive, and I have to restore it, your on the hook to your manager as the explanation.
With great power comes great responsibility, and sometimes people need to be reminded of that so they don't go chasing after the new shiny object (or language/library/etc.)
3
u/thecrumb Nov 28 '20
I'd hope everyone can 'script' and has a good understanding of how these low level tools work before slapping together something in Ansible by reading some docs and not having any idea what it's doing under the hood.
3
u/tuba_man SRE/DevFlops Nov 29 '20
I'm in the cloud, every day is both. And especially when you're dealing with stuff that isn't “cloud native” or VM-safe (cough legacy), careful scripting is sometimes the only way to keep those bits of your infrastructure manageable.
Use config mgmt principles to improve your scripts! I'm a much better scripter than I was a few years ago. Idempotence is fuckin cool for instance - write your scripts so they work like config management. every time a script runs with a given set of flags and input data, the output should always be the same. Eventually/ideally your scripts never leave silently leave your system in an unknown state.
(An example of the difference is a script that toggles a service on or off - you can just blindly toggle and hope it works, or make enable and disable required and mutually exclusive parameters. In the second, you know that even if you run it a random number of times, you'll know exactly what state the service is in at the end.)
The main thing is, like everyone said, don't reinvent the wheel. Even though it's fun. Don't script what someone else wrote if it works, don't overestimate how much customization you need.
2
u/gargravarr2112 Linux Admin Nov 28 '20
Config management is about defining a desired state for a machine/database/whatever, insofar as what should be available for use. It does not define the data that the target processes. For all intents and purposes, a script that does the latter is perfectly all right. If the script is pulling data out of one system, munging it and pushing it into another, on a regular basis, that's not a job for config management - in fact, the config manager should take that script and make sure it keeps running. So the two complement each other.
In general, automating is preferable to doing something manually. There should be absolutely no resistance to someone scripting a repetitive task, only the question 'can we do this better?' Config management is pretty abstract in what it offers - for specific tasks for your organisation, custom scripts are the best way to go about it. The config manager can then keep track of those scripts and ensure they're in use where they need to be.
2
Nov 28 '20
I work in a big environment. We have scripts running most everything. There is an initiative to spin up SaltStack to start migrating some processes to a config management tool. I don't believe it will ever fully replace scripts, simply because there are some complicated workflows that need the extra logic she ability that scripting (and calling out to. NET classes) provide.
I see config management for our environment more as a method to apply policies across the system where GPO might not work, and for standardizing build processes. Unfortunately the vast majority of our systems run vendor-provided software, and it's not conducive to deploying with config tools (or scripts, for that matter).
Scripts are great for automating pieces of workflows where people need to run them ad-hoc. I use Ansible (for now) to do base OS builds and AWX to run patching for my systems. It gives me the most bang for the buck - automation where it works, and I use scripts for other pieces where full automation isn't necessarily ready to go.
Use the tool that makes sense. In the end, IT is a force multiplier for the business. Do things that work to that end, in whatever tools make sense.
2
u/BloodyIron Head of IT Security Nov 28 '20
I wrote a script like 13 days ago to connect to a large list of systems and fix puppet on it. There's plenty of legit reasons for scripts to exist. But in the era of DevOps and Configuration Management, they likely won't be your primary tool.
2
u/Noodle_Nighs Nov 28 '20
certainly not - its the difference between seeing something is wrong and fixing it and not being able to in a reasonable time.
2
2
u/Arkrus Nov 28 '20
Don't ever let your toolbox define what you can and can't do.
Puppet/ansible/python/bash/powershell have their strengths and weaknesses, and you are better at being a jack of all trades and bringing what is nessessary to the table at the right time.
If you're concerned about ansible learn some.
2
u/m1ndfuck Nov 28 '20
Actually, some of our ansible templates are infact shell (perl) scripts that are deployed to the machines, and then installed as cronjobs.
I think it goes hand in hand.
2
u/androidul Nov 28 '20
you’re still gonna get that interview if that’s what you’re asking, just don’t make this a big thing. Keep it there in your résumé among other skills
2
u/BradChesney79 Nov 28 '20 edited Nov 28 '20
In a single word, yes. There does feel to be peer pressure to over engineer at that system level.
I learned Puppet, I like Ansible better, and have used Terraform.
I have a smaller systems that are managed better and more transparently with bash, Python, and awscli... all via scripts for repeatability and documentation via code. But still... 90% bash.
But, I just don't have the actual problems provisioning tools really are helpful for.
2
Nov 28 '20
Scripting will always be useful.
My last job consisted of maintaining VM appliances that you would destroy after every patch or upgrade. The process was, download database, deploy new VM, configure by hand the networking/system, upload DB, and destroy old VM.
These appliances were locked down tight.
Did I have access to anything underlying the OS? Could I deploy ansible or puppet if the only thing that I got a prompt for was a custom Cisco ssh shell? Not really.
Yes, I could hack a few bash scripts here or there if I went against Cisco TAC's best recommendations, but then I would lose everything each time I upgraded.
Some had linux or freebsd underlying the Appliance, but who knows what Cisco, or Infoblox would do with each software release.
Oh, and then you got the hardware appliance version of that to maintain too... better tread gingerly.
Don't get me wrong. I would install custom RHEL packages, and hack in my own scripts and monitoring tools via SNMP. Sometimes I would be so curious I would mount /root via a live cd and mess with the filesystem when I wasn't supposed too.
2
u/michaelpaoli Nov 28 '20
Is scripting (bash/python/powershell) being frowned upon in these days of "configuration management automation" (puppet/ansible etc.)?
No. Those - "configuration management automation" - tools and such, will only take one so far with configurations and point/click/drag/drool/whatever. Sooner or later one needs programs and conditionals in there too, and often that means scripting ... and some of those "configuration management automation" tools/software have their own scripted languages ... which seems kind of a waste, when there already exist perfectly good scripting and configuration languages - why learn yet another special snowflake one for some special snowflake tool/software?
2
u/MadeUntoDust Nov 28 '20
I create cloud resources with Terraform and manage on-premise local resources with Ansible. But whenever I encounter the limitations of either, I fill in the gap with a little shell script or Python program.
2
u/nginx_ngnix Nov 29 '20
I had some DevOps guys tell me that I write too many shell scripts.
But they also just don't understand machines that have cronjobs.
And are perfectly happy with putting the equivalent of, like, a ten line shell script in a nearly unreadable Makefile filled with 10x 120 character long docker commands running one command at a time in a container...
2
u/ddxx398 Nov 28 '20
Configuration is more infrastructure. I mean sometimes you gotta script something to get the job done. Ansible isn’t designed for that. So if anyone is frowning, they are either from a big shop, fake developers who are salesman, I’d never scripted to put out a fire in there life.
2
1
u/notauniqueusernom Nov 28 '20
I’ve personally never seen so much shell since Ansible became popular - it’s almost like all the hard learned lessons have been unlearned.
1
u/BigRedMachine1313 Nov 28 '20
I feel to better understand what the tools are doing it's good to have a scripting background. This allows for admins to do more complicated tasks based on their environment.
1
u/BarServer Linux Admin Nov 28 '20
No, they are 2 different tools, for different use cases. Our team has tons of small scripts which we use to automate tasks or make some stuff easier/quicker.
Even if you use configuration management (Puppet in my case) you still have to write ruby scripts regularly as Puppet doesn't solve everything.
And CM won't help you when you want a script to do something against some internal API from your workstation for a task where automation makes no sense.
1
u/whit_wolf1 Site Reliability Engineer Nov 28 '20
NOT at all... it only compliments the latter when implemented properly.
1
u/wildcarde815 Jack of All Trades Nov 28 '20
I do a whole lot of both. Ie, puppet pushes out the config for automysqlbackup and my home grown postgresql backup but those are just shell scripts with config files.
1
u/harrywwc I'm both kinds of SysAdmin - bitter _and_ twisted Nov 28 '20
as many have noted, often the 'configuration management automation' tool(s) will fire off a script in bash/poweshell/php/python/etc.
there is always some "work" that has to be done somewhere. add to that, those tools don't cover 100% of use-cases - and so custom scripts will also be required there.
1
u/redingerforcongress Nov 29 '20
Perhaps you should take a look at what Ansible is actually written in - particularly a windows module.
https://github.com/ansible/ansible-modules-core/tree/devel/windows
You'll find your "scripts" there :)
1
u/MelatoninPenguin Nov 29 '20
Sounds like your working in VFX
Lot of more talented artist in my opinion should be allowed to run their own scripts locally or access certain files - many are quite good at python
1
u/robvas Jack of All Trades Nov 28 '20
You shouldn't be doing configuration changes, or configuring new machines, with bash, across your network. Those are the things you should be using puppet/ansible for.
1
u/HayabusaJack Sr. Security Engineer Nov 28 '20
You still have legacy kit to deal with where tools like ansible and even python don’t work. Scripting is key in those areas. Heck due to legacy kit, even bash isn’t available so my current script library is running on ksh. Plus there are shops where legacy kit and short staff prevent automation.
0
u/therealmrbob Nov 28 '20
Configuration automation is just a delivery method for scripts. So... no, it’s not going to replace scripts.
2
u/kdegraaf Nov 28 '20 edited Nov 29 '20
Configuration automation is just a delivery method for scripts.
That's not even remotely true in the case of declarative state-management tools like Puppet.
Edited to add: Apparently, I need to clarify my position. For context, I've worked with a large number of folks who are under the impression that you write a custom script in bash, Python or the like, one that is procedural in nature ("do this, that, and the other thing"), then use Puppet to distribute it out and execute it.
This, of course, is utterly different from how a declarative state-management tool ("use generic primitives to make my system look like X") operates.
If you're going to argue that Puppet's types, providers, facts, functions, etc. qualify as "scripts", then sure, I guess the idea that it's a script-delivery mechanism is at least somewhat plausible.
But I think that rests on a non-standard understanding of "script". To my mind, that term evokes a quick, dirty, organization-specific hack written in shell/Perl/Python/PowerShell, as opposed to the more polished, general-purpose, declarative-model components you'll find in a mature CM platform. To me, those aren't "scripts", they're just "software" -- and if you write your own facts/functions/T&Ps, they'd fall into the latter category.
Potato, potahto, I suppose.
0
u/therealmrbob Nov 28 '20 edited Nov 28 '20
Yeah, if you just use the out of the box stuff, I imagine you would be hard pressed to find a puppet environment that doesn’t have custom functions and facts.
Edit: to be fair, haven’t used a ton of puppet, but I’ve used dsc, chef, and ansible and most of the stuff we used those for was custom code. Not to say that it doesn’t provide some value outside of delivering that code, but it’s kind of a big part of it.
0
0
Nov 28 '20
[deleted]
13
u/Superb_Raccoon Nov 28 '20
To be fair, Ansible is scripting... the COBOL of scripting.
-6
u/gordonv Nov 28 '20
WTF? Cobol is directly comparable to Assembly. Ansible is one of the highest levels of popular abstraction that exists today.
35
u/Superb_Raccoon Nov 28 '20 edited Nov 28 '20
You know nothing of COBOL, the COMMON BUSINESS ORIENTATED LANGUAGE.
It was intended to allow business people to "write code"
Thus COBOL looks like this:
(Apologies for the formatting issues, Reddit copypasta sucks)
IF NUM1 IS LESS THAN NUM2 AND NUM1 IS LESS THAN 100 THEN
DISPLAY 'COMBINED CONDITION'
ELSE
DISPLAY 'NAH' END-IF *> checking for negative or positive values
IF NEG-NUM IS POSITIVE OR NEG-NUM IS NEGATIVE THEN
DISPLAY 'A NUMBER IS POSITIVE'.While assembler looks like this:
call disp1
call read1 ; read name of file to be
lea dx, buffer1[2] ; created
0 mov cx, 0
mov ah, 3ch ; create the file
int 21h
push ax ; push file handle onto stack.While Ansible looks like this:
hosts: dbserver tasks:users user: name={{ item.name }} pass={{ item.pass }} groups ={{ item. groups }} state=present with_items:
- name: Create multiple
groups : wheel }
- { name: db1, pass: db123,
groups : "wheel, mysql" }
- { name: db2, pass: db123,
As you can see, Ansible has far more in common with COBOL than Assembler.
When COBOL was developed (1958) the language of choice was Assember or Machine Language.
COBOL was FAR more readable than either of those options.
→ More replies (31)6
u/rollingviolation Nov 28 '20
WHY IS COBOL ALWAYS YELLING?/s
3
5
Nov 28 '20
ansible integrates directly with python, and puppet is easy to extend/integrate as necessary with ruby.
2
u/Willbo Kindly does the needful Nov 28 '20
If you decide to use Ansible for Windows, you will find it uses WinRM with PowerShell and you will be absolutely stuck if you don't know a bit of PowerShell.
2
u/jimicus IT Manager Nov 28 '20
If you decide to use Ansible for Windows and Powershell intimidates you, you have no business using Ansible for Windows.
1
u/andolirien Nov 28 '20
This exactly was what I was going to say. In my experience so far with Ansible, it's an extension of my scripts, or works hand-in-hand to get the job done. I'll search for modules, or commonly used ways to create tasks and make things happen, but then I can fill in the gaps that are unique to my ecosystem with certain scripts that come along for the ride. It's not an either/or situation. :)
0
Nov 28 '20
[deleted]
3
0
Nov 28 '20
[deleted]
1
Nov 28 '20
You're not wrong, but I would point out that if you're using DSC, you're basically using the equivalent of Ansible on Windows, ie, a configuration management tool. It just happens that DSC is powered by Powershell.
0
0
Nov 28 '20
[deleted]
4
u/vrillco Nov 28 '20
Maybe I’m just getting old, but I see Ansible as a really ugly bodge built atop some pretty decent “modules”. I’d much rather use those modules directly in Python than have to wrap them in the abomination that is YAML.
2
u/brontide Certified Linux Miracle Worker (tm) Nov 28 '20
This is so true, (ansible-yaml) would be far more like chef or salt and likely be a far more enjoyable. Heck, raise you hand if you've been bitten by the
mode: 0644bug, forgetting to quote it means it's interpreted as a number resulting in totally different permissions being set. I've had to write my own library modules and they are not fun or easy to write. The recent upgrade wagon is also frustrating having a large number of workaround/fixes needing to be applied for each and every minor release is a PITA.The absolute inability for ansible to have any reasonable branching or looping.
Note: Yaml is overall an abomination. Designed to be "easy on the eyes" has a closet full of gotchas just waiting to jump out and bite. The one that still bugs me is numbers. In a docker compose you map
external:internalports. Seems easy enough but get this....
1000= is map port 1000 to port 1000
1000:8080= map port 1000 to port 8080
"53"= map port 53
53:1053= map port 53 to port 1053
53:53= map the port 2653 ( the decimal conversion of 53 in base 53 )You have to quote everything or else you can end up with obscure bugs.
0
Nov 29 '20
[deleted]
1
u/gordonv Nov 29 '20
It's only a colloquialism. We all know we can do pretty much magic with the right imports and commands.
The nature of Python is to be light hearted. Call it whatever you want.
1
u/Misocainea DevOps Nov 29 '20
Python is, by definition, a scripting language. Scripting languages are interpreted at runtime whereas programming languages are compiled and do not require an interpreter.
34
u/justinDavidow IT Manager Nov 28 '20
Configuration-management and scripting are not mutually exclusive.
Automation is about saving time, making things more consistent, and being able to clearly quantify the changes you made in a commit.
Sometimes it makes sense to automate deploying a script, sometimes it makes sense to lean more on the configuration-management tool to setup the primitives for you.
Is your environment heterogeneous? If so then good luck scripting the same "thing" across 15+ (or however many different platforms you run)
In my environment we automate a combination of AWS, GCP, Azure, dedicated Centos (6, 7, and 8) nodes, Debian (various flavors), OSX, Windows 8/10, Android, IOS, (etc). (Not to even mention dedicated storage or network gear!) Writing a "script" that does the same "thing" across multiple platforms would lead to me wasting a week trying to script the similar action on each different platform.
For example:
If I need to transform 500+ items on a single platform (IE dump a specific range of tables from each of the 10 RDS instances in 10 different AWS accounts, create a new GCP cloudSQL instance for each of the 100 new DB's, import the data, configure table-limoted replication, setup "on changed row" trigger actions on the old instances, ensure that the replicas catch up, then perform a DNS update for 100 different endpoint addresses:
I'd likely write most of the above in Terraform with a custom provisioner script to handle the client-specofic bits that are not going to make to TF native components well.
This has the advantage that multiple people can work on this automation / script together, and overall (once written) will work well without interaction (time).
It also comes with the disadvantage that it has a high initial setup time requirements (unless everything is already managed in Terraform!) It MIGHT be simpler and preferred to simply script the API calls to the aforementioned services directly, it may save time and is unlikely to be reused in the future or need to "stay in that state".
Personally I prefer Puppet for configuration-management of "need to stay like this" automation, and Ansible for repeated "task" automation; but for one-off tasks I'd still write a bash script any day of the week. I can simply write a bash script faster than I can map the needs of the task to various automation components.