Joomla - Get Latest Version Zip Link - scrip Install - joomla

Does Joomla have a Link to the Latest Version? Wordpress for example has a link to https://wordpress.org/latest.zip , so I know I can always download that zip and get the latest version.
I am working on ansible script to automatically setup a server and install joomla and I need to keep it simple so I would like to spesify a link or api call or something to always get the latest joomla version zip.
Any help appreciated.
David

good question - it is certainly not as easy as wordpress.
You can download the latest version using ansible in the following way:
Download the XML file you mentioned to your local machine:
- name: download latest joomla packages list to local machine
tags: joomlanew
get_url:
url: https://update.joomla.org/core/sts/extension_sts.xml
dest: "{{ role_path }}/scripts/extension_sts.xml"
force: yes
delegate_to: 127.0.0.1
Run a python script to parse this XML to find the latest package zip file:
- name: find latest joomla version
tags: joomlanew
command: python ./latest_joomla.py
args:
chdir: "{{ role_path }}/scripts"
delegate_to: 127.0.0.1
register: xmlresp
You can then use {{ xml.resp.stdout }} in ansible as the input for your download code:
- name: download & unzip joomla
tags: joomlanew
unarchive:
src: "{{ xmlresp.stdout }}"
dest: /home/username/public_html/
remote_src: yes
mode: 0755
FYI the code in th python script to parse the XML would be:
from xml.dom import minidom
xmldoc = minidom.parse('extension_sts.xml')
itemlist = xmldoc.getElementsByTagName('downloadurl')
last=(len(itemlist))-1
print (itemlist[last].firstChild.data)

Ok after some digging I guess the best way to go after this is the way Joomla Core does it:
Get detailsurl out of Last entry out of the Joomla Core Update site (https://update.joomla.org/core/list.xml) - in this instance https://update.joomla.org/core/sts/extension_sts.xml
Get downloadurl out of Last entry out of the url you got in step 1 - in this instance - you need to make sure this is not a PATCH url but UPDATE

You can use this link to download the latest version: https://github.com/joomla/joomla-cms/archive/staging.zip

Related

Ansible: 'shell' not executing

I'm trying to run a shell command to install a package downloaded from my local Artifactory repository, as I don't have access to download it straight from the internet.
When I run the command directly on the node as such
rpm -ivh kubectl-1.1.1.x86_64.rpm --nodigest --nofiledigest
It works perfectly.
But then put in Ansible playbook as such
- name: Install Kubectl
shell: rpm -ivh kubectl-1.1.1.x86_64.rpm --nodigest --nofiledigest
Nothing happens.
It doesn't error.. It just doesn't install.
I've tried the command and ansible.builtin.shell module as well, but nothing works.
Is there a way to do this please?
There are different topics in your question.
Regarding
to install a package downloaded from my local Artifactory repository, as I don't have access to download it straight from the internet.
you can use different approaches.
1. Direct download
- name: Make sure package becomes installed from internal repository
yum:
name: https://{{ REPOSITORY_URL }}/artifactory/kube/kubectl-{{ KUBE_VERSION }}.x86_64.rpm
state: present
2. Configure local repository
The next one is to provide a .repo template file like
[KUBE]
name = Kubectl - $basearch
baseurl = https://{{ REPOSITORY_URL }}/artifactory/kube/
username = {{ API_USER }}
password = {{ API_KEY }}
sslverify = 1
enabled = 1
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-KUBE
and to perform
- name: Make sure package becomes installed from internal repository
yum:
name: kubectl
state: present
This is possible because JFrog Artifactory can provide local RPM repositories if configured correctly. For more information you research the documentation there since it is almost only about proper configuration.
Regarding
Nothing happens. It doesn't error.. It just doesn't install.
you can use several task to split up your steps, make them idempotent and get an better insight how they are working.
3. shell, rpm and debug
- name: Make sure destination folder for package download (/opt/packages) exists
file:
path: "/opt/packages/"
state: directory
- name: Download RPM to remote hosts
get_url:
url: "https://{{ REPOSTORY_URL }}/artifactory/kube/kubectl-{{ KUBE_VERSION }}.x86_64.rpm"
dest: "/opt/packages/kubectl-{{ KUBE_VERSION }}.x86_64.rpm"
- name: Check package content
shell:
cmd: "rpm -qlp /opt/packages/kubectl-{{ KUBE_VERSION }}.x86_64.rpm"
register: rpm_qlp
- name: STDOUT rpm_qlp
debug:
msg: "{{ rpm_qlp.stdout.split('\n')[:-1] }}"
- name: Install RPM using 'command: rpm -ivh'
shell:
cmd: "rpm -ivh /opt/packages/kubectl-{{ KUBE_VERSION }}.x86_64.rpm"
register: rpm_ivh
- name: STDOUT rpm_ivh
debug:
msg: "{{ rpm_ivh.stdout.split('\n')[:-1] }}"
Depending on the RPM package, environment and configuration, all may just work good.
Try use command module and register the output i use it to install oci8 by pecl for oracle database on linux

How to only download an appimage if the version doesn't match the existing in ansible

I want to download the latest appimage of bitwarden, but only if the downloadable version is newer than the local one.
- name: Download and place Bitwarden Appimage
get_url:
url: "https://vault.bitwarden.com/download/?app=desktop&platform=linux"
follow: yes
dest: /home/user
register: foo
when: foo !== /home/user/Bitwarden-{1....9}-x86_64.AppImage
Is it possible to do this within the same task, or do I have to split it up over 2? Also is the regex syntax correct? The current version is: 1.25.1

Ansible yum disablerepo does not work if repo is not installed

I have a number of different Centos7 servers running. I like to use ansible to update them all at once.
As one of my servers has an additional repository enabled, which I do not want to update. I've added to the playbook the option to disable this repo. This works as expected.
However, on my other servers, I did not install and enable this repo. When using the disablerepo in my ansible playbook, I get an error: repository not found.
How do I solve this in the ansible-playbook? Is it possible to add an condition like, if repo installed; then disablerepo; else do nothing?
Is it possible to ignore these errors?
ansible-playbook:
---
- hosts: [all]
tasks:
- name: update all packages to lastest version
yum:
name: '*'
state: latest
disablerepo: sernet-samba-4.2
you can put ignore_errors: yes as in the link from the comment, or you can put when, only if certain package is installed, sure you have to register them to variables first, I'm thinking something like:
- name: check if installed
shell: rpm -qa sernet-samba-4.2
register: is_installed
- name: update all packages to lastest version
yum:
name: '*'
state: latest
disablerepo: sernet-samba-4.2
when: is_installed.rc == 1
Warning: Untested.
After a day of research in internet and experiments finally found a solution that worked. Try to use wildcard.. then it will not fail when repo is missing.
yum:
name: ''
state: latest
disablerepo: sernet-samba

Can ansible get a url from an anchor on a webpage?

I want Ansible to install a .deb package from a url when the url changes every week (because of updates). There is an anchor to the dynamic download url on a static download page. Is there a trick to have ansible figure out the url?
E.g. on a certain page, there is a link called "Latest version" as so:
Latest version.
Can I get ansible to get URL_TO_DOWNLOAD_DEB?
Here is some made-up trick that hopefully illustrates what I mean. Obviously, this does not work.
- name: Find link to DEB package
regex_from_url:
url: http://some.download.page
regex: g/<a href="([^"]+)">Latest version<\/a>./
register: URL_TO_DOWNLOAD_DEB
- name: Install DEB package
apt:
deb: {{ URL_TO_DOWNLOAD_DEB }}
You can try something like this:
- name: Send GET request to target
shell: wget -O - http://some.download.page | grep '>Latest version<' | sed -n 's/.*href="\(.*\)".*/\1/p'
register: web
args:
warn: False
- name: Show download link
debug:
msg: "{{ web.stdout }}"

How can I run a command only if an online file has changed in ansible

I have the following task in my ansible playbook:
- name: download last buildtools
get_url:
url: https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
dest: ~/buildtools/BuildTools.jar
I want the following command to be run only if the BuildTools.jar file has changed:
java -jar BuildTools.jar --rev latest
How can I do this in my ansible playbook ?
EDIT: Just to be clear, I want the command to be triggered only if the version of the file at the url above has changed. So, in the case, each time a new version of minecraft is supported by the buildtools.
Finally, I found an elegant way to do what I wanted:
From the doc of the force parameter in the get_url module,
If yes and dest is not a directory, will download the file every time and replace the file if the contents change.
So my config is now:
- name: Download the last buildtools
get_url:
url: https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
dest: ~/buildtools/BuildTools.jar
force: yes
register: buildtools
- name: Update BuildTools
command: java -jar BuildTools.jar --rev latest
args:
chdir: ~/buildtools/
when: buildtools.changed
So the Update BuildTools task is only run if the file downloaded at the url is different of the original file on the server, or if it is the first time that the file is downloaded.

Resources