Setting Repo with Puppet for Debian - puppet

I am trying to just set a repo in Ubuntu that is not centrally managed repo. In the past I worked on CentOS at work and would just use the yumrepo resource definition to do this. But, now I'm in an Ubuntu shop and that won't work. The Puppet docs say I need to use dpkg to do this, but I cannot find anything in the docs over dpkg, only yumrepo. I'm a tad confused and would appreciate someone clearing this up. Seems like it shouldn't be hard and it also seems like something I shouldn't have to install a third party module for, but that's the only solution I've seen people recommending online and that's just not an option for me. Thanks.

Puppet has a supported module puppetlabs/apt that you should use on Ubuntu Linux. Also, as noted in the Puppet 6 release notes, the yumrepo type has also moved to an external module now, which has resolved the inconsistency you alluded to in the way Red Hat was previously treated as more of a first-class citizen in the Puppet ecosystem, which was never really the intention.

This creates a Debian repository using the apt class pointing to any server you want, local or remote:
apt::source {
"$lsbdistcodename":
include_src => false,
location => "http://10.0.0.8/debian/$lsbdistcodename",
repos => "main contrib non-free",
;
}

Related

How to downgrade Terraform to a previous version?

I have installed a version (0.12.24) of Terraform which is later than the required version (0.12.17) specified in our configuration. How can I downgrade to that earlier version? My system is Linux Ubuntu 18.04.
As long as you are in linux, do the following in the terminal:
rm -r $(which terraform)
Install the previous version:
wget https://releases.hashicorp.com/terraform/1.3.4/terraform_1.3.4_linux_amd64.zip
unzip terraform_1.3.4_linux_amd64.zip
mv terraform /usr/local/bin/terraform
terraform --version
That's it, my friend.
EDIT: I've assumed people now use v1.3.5 so the previous version is v1.3.4.
You could also checkout Terraform Switcher - this will allow you to switch between different versions easily.
First, download latest package information using:
sudo apt-get update
The simplest way to downgrade is to use apt-get to install the required version - this will automatically perform a downgrade:
Show a list of available versions - sudo apt list -a terraform
terraform/xenial 0.13.5 amd64
terraform/xenial 0.13.4-2 amd64
... etc
or use sudo apt policy terraform to list available versions
Install the desired version:
sudo apt-get install terraform=0.14.5
Or, for a 'clean' approach, remove the existing version before installing the desired version:
sudo apt remove terraform
There are other valid answers here. This may be useful if you have a situation, like I do, where you need multiple Terraform versions during a migration from an old version to a new version.
I use tfenv for that:
https://github.com/tfutils/tfenv
It provides a modified terraform script that does a lookup of the correct terraform executable based on a default or based on the closest .terraform-version file in the directory or parent directories. This allows us to use a version of Terraform 0.12 for our migrated stuff and keep Terraform 0.11 for our legacy stuff.
You shouldn't be installing terraform in ubuntu any more. Generally speaking, the industry has moved on to docker now. You can install docker like this:
sudo apt install -y curl
curl -LSs get.docker.com | sh
sudo groupadd docker
sudo usermod -aG docker $USER
Once installed you can run terraform like this:
docker run -v $PWD:/work -w /work -v ~/.aws:/root/.aws hashicorp/terraform:0.12.17 init
Assuming that your .aws directory contains your aws credentials. If not, you can leave that mount binding (-v ~/.aws:/root/.aws) out of the command and it'll work with whatever scheme you choose to use. You can change the version of terraform you are using with ease, without installing anything.
There are significant benefits in this approach over the accepted answer. First is the ease of versioning. If you have installed terraform using a package manager you can either uninstall it and install the version you need, or you can play around with Linux alternatives (if your distro supports them, or you are using Linux, or a package manager of some sort -- you could be using Windows and have downloaded and run an installer). Of course, this might be a one-off thing, in which case you do it once and you're ok forever, but in my experience, that isn't often the case as most teams are required to update versions due to security controls, and those teams that aren't required to regularly update software probably should be.
If this isn't a one-off thing, or you'd not like to play around too much with versioning then you could just download the binary, as one comment on this post points out. It's pretty easy to come up with a scheme of directories for each version, or just delete the one you're using and replace it completely. This may suit your use-case pretty well. Go to the appropriate website (I've forgotten which one -- Hashicorp or the GitHub repo's releases page, you can always search for it, though that takes time too -- which is my point) and find the right version and download it.
Or, you can just type docker run hashicorp/terraform:0.12.17 and the right version will be automagically pulled for you from a preconfigured online trusted repo.
So, installing new versions is easier, and of course, docker will run the checksum for you, and will also have scanned the image for vulnerabilities and reported the results back to the developers. Of course, you can do all of this yourself, because as the comment on this answer states, it's just a statically compiled binary, so no hassle just install it and go.
Only it still isn't that easy. Another benefit would be the ease in which you could incorporate the containerised version into docker-compose configurations, or run it in K8S. Again, you may not need this capability, but given that the industry is moving that way, you can learn to do it using the standardised tools now and apply that knowledge everywhere, or you can learn a different technique to install every single tool you use now (get some from GitHub releases and copy the binary, others you should use the package manager, others you should download, unzip, and install, still others should be installed from the vendor website using an installer, etc. etc. etc.). Or, you can just learn how to do it with docker and apply the same trick to everything. The vast of modern tools and software are now packaged in this 'standard' manner. That's the point of containers really -- standardisation. A single approach more-or-less fits everything.
So, you get a standardised approach that fits most modern software, extra security, and easier versioning, and this all works almost exactly the same way no matter which operating system you're running on (almost -- it does cover Linux, windows, osx, raspbian, etc.).
There are other benefits around security other than those specifically mentioned here, that apply in an enterprise environment, but I don't have time to go into a lot of detail here, but if you were interested you could look at things like Aqua and Prisma Cloud Compute. And of course you also have the possibility of extending the base hashicorp/terraform container and adding in your favourite defaults.
Personally, I have no choice in work but to run windows (without wsl), but I am allowed to run docker, so I have a 'swiss army knife' container with aliases to run other containers through the shared docker socket. This means that I get as close to a real Linux environment as possible while running windows. I dispose of my work container regularly, and wouldn't want to rebuild it whenever I change the version of a tool that I'm using, so I use an alias against the latest version of those tools, and new versions are automatically pulled into my workspace. If that breaks when I'm doing, then I can specify a version in the alias and continue working until I'm ready to upgrade. If I need to downgrade a tool when I'm working on somebody else's code I just change the alias again and everything works with the old version. It seems to me that this workflow is the easiest I've ever used, and I've been doing this for 35 years.
I think that docker and this approach to engineering is simpler, cleaner, and more secure than any that has come before it. I strongly recommend that everyone try it.

Can one just copy perl modules from one Linux machine to another?

I have a remote CentOS server (Release 6.10) set up by someone else. I have quite a few perl modules installed on the machine.
I have set up a local CentOS server (Release 7.7.1908). I would like to have the EXACT same set of perl modules on my local machine. Installing them one by one via cpan is an option but I can run into issues as some of the perl modules are older (very) versions.
I was wondering, if I can copy modules from the remote server to my local server. Can I do that? Are there other options?
It's not safe to copy modules from one machine to another because things may not be set up identically. It's best to reinstall them.
You can use the autobundle command in the cpan shell to create a dump of all the modules you have installed on the old machine. You can then use that dump to tell the cpan shell on the new machine what modules to install.
Thanks to Polar Bear, here's a link to an article that explains how to reinstall the autobundle.
The solution suggested by Andy Lester is perhaps the best way to do it. I found a documentation here in addition to ones suggested.
In my case however this was not straight forward because the source server environment is very old and there were many dependencies that I will need to manually resolve. In general if you have similar environments and clean installs, the auto bundle approach will make it easy.

How to install dorodango package manager Scheme language

I needed to use Purely Functional Data Structures in Scheme (pfds),
so I found a resource for it (https://github.com/ijp/pfds). I cloned
it using git command, and so far successful.
I have racket installed and needed these pfds to work. For which
first I had to install the pfds using a package manager called “dorodango” to
install pfds on Gitlab (https://gitlab.com/rotty/dorodango.git).
So the problem now is that how I install dorodango package manager from
the resource I found on Gitlab.
Can someone help? Please.
Whoa! If I understand you correctly, this is Much Easier than you think.
First, though, it looks to me like you need to back up many steps.
To install the pfds package for racket, you need to do one (and only one) of these two things. Either:
run raco pkg install pfds from the command-line, or if you're not a command-line person,
Use the package manager built into DrRacket.
No need to git clone anything, no need to use dorodango. Perhaps I'm misunderstanding something about your situation?
(For more information, check out the Getting Started with Packages.)

gitlab 6.6.5 community centos rpm - can't figure out how to launch rails console

Environment:
OS: Centos 6.5
GitLab: gitlab-6.6.5_omnibus-1.el6.x86_64.rpm (installed as root user)
Hello all,
I am attempting to figure out how to launch rails console for the gitlab application so I can take a look a the data as needed.
Based on what I read in the documentation it should be stored in /home/git/gitlab but when I change to my git user there isn't a gitlab directory. I did see that there is something familiar in /opt/gitlab/embedded/service/gitlab-rails but since I am logged in as root I don't seem to have anything in my path to execute.
Should I not have installed this as root since all of the documentation for installation is using sudo? If I do have to use something other than root for the install, is simply uninstalling the RPM good enough or do I need to re-install the entire OS?
If my system is ok being installed as root, can anyone tell me where I can find the documentation related to administering gitlab or at the very least the documentation on how to view the data? The documentation that I have found is as of version 5 and it doesn't look like it applies to 6. Again I could be wrong if I installed this incorrectly.
Thanks in advance.
I'm a little disappointed that there doesn't appear to be any documentation for how to install gitlab from RPM, however, I think I've managed to figure it out.
Download and install the .rpm for Centos from https://www.gitlab.com/downloads/
Run: /opt/gitlab/bin/gitlab-ctl reconfigure
Browse to http://example.com:80 and log in with the following creds:
username: admin#local.host
password: 5iveL!fe
I would be cautious of using the above steps for deploying a production site (especially one exposed to the internet) because many of the services seem to be running as root. I'll be doing a bit more reading to see if I can restrict this further.
Also, configuration looks like it's located under: /var/opt/gitlab/gitlab-rails/etc.
Good luck!
Bowen
Reviving an old question, but the answer is:
sudo gitlab-rake rails console

install/manage ntp on ubuntu 11.04 using puppet

I have looked at some of the puppet-ntp packages on git and other places, but its not clear on exactly HOW they would be installed. It seems most of them are focused on a puppet server pushing ntp or ntpd to clients. But what if i have just ONE host, which i want to manage, and have NO puppet server. so in that case can i use:
package { 'ntp': ensure => 'installed', }
If so , then at least puppet site should mention it. The idea is to have this package in a ntp.pp file and run puppet apply ntp.pp command.
I am not sure what was your intent of asking this question but if you just want to use puppet to install just a package, you can also use:
puppet resource package ntp ensure=present

Resources