How to upgrade the existing software/tools installed using Ansible - ansible

I have requirement to upgrade existing tools/software installed on servers (used for DevOps Agentpool) using Ansible. Can anyone share sample YAML code and steps involved to upgrade.
Tools to upgrade like Java 11 to 18, Git, Maven etc.

Basically the up mentioned code:
- name: update java 8
package:
name:
- java-1.8.0-openjdk-headless
- java-1.8.0-openjdk
- java-1.8.0-openjdk-devel
state: latest
What really does is install the latest version of the package for those in the list which implies the upgrade of it or replacement of the old with the new one.
Disclaimer: this is code is provided as it is. Not necessarily will resolve your problem.
If you want a better answer, probably need to provide more information or give a better example of what you want to do or your intention.

This kind of question probably should include the OS of the target. Assuming you're running rpm/yum based linux, something like this would work:
- name: update java 8
yum:
name:
- java-1.8.0-openjdk-headless
- java-1.8.0-openjdk
- java-1.8.0-openjdk-devel
state: latest

Related

Installing a RPM package without deinstalling the old one

Does anybody know what would happen if a package gets installed, while the old package remains installed? The thing is that the command rpm -e <rpm_package> will uninstall and delete the old package. In my case, I want to keep the old package as a backup and I don't want it to get erased.
Is it possible to keep the old package available in the file system(without deleting it) while having installed the new one?
Thanks in advance!
Yes, this is possible. It is not documented, but when you install an RPM with both the
--nodeps and --force options
It turns out yum really does disable ALL dependency logic
This is the other way to get into the state of having duplicates besides:
you terminate rpm during the transaction.
If you don't believe me give it a try on a CentOS 7 server. It's possible this behavior has changed in dnf - after all it was meant to be an upgrade to yum. That would not shock me.
No, it is not possible.
It can happen that you have two package of the same name. But that is only possible when:
you terminate rpm during the transaction. You can then remove the correct one using full NEVRA. I.e., rpm -e bash-5.1.8-2.fc35.x86_64
when packages are multilib. I.e., one is i386 and the other x86_64
If you want to keep backups then I recommend either using 'local' plugin https://dnf-plugins-core.readthedocs.io/en/latest/local.html Just be aware that it can consume a lot of storage.
Or even Red Hat Satellite, which allows you easy rollbacks. But that is likely big beast for your needs.

Issue with ansible logic to patch system

I am updating my CentOS role to patch systems after Frozen repos have been configured and non-Frozen repos are removed. I am finding that, if use the logic below, it restores the CentOS repos after ansible already removed them:
- name: Patch the System
yum:
name: '*'
update_cache: yes
state: latest
If I remove the task above, the CentOS repos don't regenerate. What am I missing? Is there additional logic or a more efficient way to patch systems?
Resolved issue by breaking out "find and removing non-frozen repo files" into separate task file that is called unconditional before patching and conditional after patching (when task reports a change)
What this does is that it checks if there are updates available (it is comparable with apt-get update) and then install/updates all(*) packages to the latest version

How to download and install ansible modules?

I have found this DNSimple ansible module:
http://docs.ansible.com/ansible/dnsimple_module.html
but can not find anywhere on that page to download and install it? How do I go about downloading and installing ansible modules like this. Thanks.
The accepted answer solved the questioner's problem but didn't address the broader scope of the question.
How to install an Ansible module? The documentation is currently vague as to how to achieve this simple requirement!
An excellent general guide to writing modules (I've no connection to the author) can be found here.
The quickest way is to simply have a folder called library/ in the same folder as your playbook. Inside this folder, place the python script for the Ansible Module. You should now have a corresponding task available to your playbook.
If you want to share your module across multiple projects, then you can add an entry to /etc/ansible/ansible.cfg pointing to a shared library location, eg:
library = /usr/share/ansible/library
The module itself is part of ansible since version 1.6 (as stated here). To use it, you need to have dnsimple on your host machine (also stated in the above description). Install it with sudo pip install dnsimple
It is important to know that base ansible modules are not installed by default on devel version, which is the default installed version when you build from source.
Only few modules are present for developpment purpose.
So when you'll run your playbook it'll complain about not found module with following error message
couldn't resolve module/action 'xxx'
If you have no choice but building for source, don't forget to checkout the stable branch to install all basic ansible modules!

Codis - Redis cluster proxy installation

I am exploring a production-stable proxy for redis cluster called codis . It is a mentioned as a great alternative to twemproxy, especially as one of my needs is pipelining and twemproxy does not offer that.
However the documentation in English is still a WIP and the replies to github issues are in mandarin.
I am trying to install this on
Linux version 3.13.0-74-generic (buildd#lcy01-07) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #118-Ubuntu SMP
I have installed go version 1.8 and I can see the folder /usr/local/go/bin. I have added this to the PATH variable as well.
However, when on executing the command go get -u -d github.com/CodisLabs/codis, I am getting the following :
package github.com/CodisLabs/codis:
no buildable Go source files in /home/ubuntu/go/src/github.com/CodisLabs/codis
You probably want to use the updated install outlined at https://github.com/CodisLabs/codis/issues/1180#issuecomment-286660086
seems the English docs might be out of date https://github.com/CodisLabs/codis/issues/1179#issuecomment-286662505

How to create a debian package from ruby source code?

We are trying to create a debian package from ruby source code. It's for fluentd software. We know that a pre-built debian package for fluentd already exists. But because of the build systems in our ocmpany we have to create a debian package manually.
We did try out deb2gem to create a deb package source but running into issues while building it.
Any pointers about how to build a debian package from scratch - using ruby source code would be helpful.
So here are the steps I followed.
Our work environment - doesn't let outside connections from the production hosts. So I can't just gem install fluentd.
Since it's a debian Wheezy build, I need to build a debian package and install on it. We can't download the binary debian package which fluentd provides and use it - so I have to build it from source.
So, I followed this procedure:
Download the actual gem of fluentd from here - https://rubygems.org/gems/fluentd
Then use gem2deb tool to create a debian source files/templates. The debian/control file looks like this - http://pastebin.com/CHJXdJMi
So when I run debuild -uc -us -b now - technically it should build a .deb package. But I get errors like these - http://pastebin.com/fEYFARRQ
The ruby version on the host I am doing is 2.3.1 But I think gem2deb uses ruby 1.9.1. And fluentd needs ruby >=1.9.3 to build it from source.
So this is where I am stuck at. I think if I don't use gem2deb then I have to figure out a way to just checkout the source code of fluentd from git and build a debian package from scratch.
There is not much info about how to go about that anywhere except this - https://wiki.debian.org/Teams/Ruby/Packaging
Appreciate any help in advance!
Thanks

Resources