Skip to content
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

[ansible/artifactory] Upgrade fails on Ubuntu 22.04 during the Check artifactory version task #365

Closed
dlundgren opened this issue Jan 11, 2024 · 17 comments · Fixed by #369
Closed
Labels
bug Something isn't working

Comments

@dlundgren
Copy link
Contributor

Is this a request for help?:

No, I solved it locally by removing set -o pipefail; and running the role again.

Is this a BUG REPORT or FEATURE REQUEST? (choose one):

BUG REPORT

Which installer:

Ansible role/artifactory

Which product and version (eg: ansible & collection version - 7.24.2):

Collection version 10.16.4

Which operating system and version(eg: ubuntu & version - 20.4):

Ubuntu 22.04

Which product license (Enterprise/Pro):

Pro

JFrog support reference (if already raised with support team):

N/A

What happened:

fatal: [artifactory]: FAILED! => {"changed": false, "cmd": "set -o pipefail;\ngrep artifactory.product.version \"/opt/jfrog/artifactory/app/artifactory.product.version.properties\" |cut -d= -f2\n", "delta": "0:00:00.005163", "end": "2024-01-11 04:30:05.221634", "msg": "non-zero return code", "rc": 2, "start": "2024-01-11 04:30:05.216471", "stderr": "/bin/sh: 1: set: Illegal option -o pipefail", "stderr_lines": ["/bin/sh: 1: set: Illegal option -o pipefail"], "stdout": "", "stdout_lines": []}

What you expected to happen:

That the role upgraded Artifactory.

How to reproduce it (as minimally and precisely as possible):

Run the role against Ubuntu 22.04 (after having Artifactory already installed) and use the following variables

artifactory_upgrade_only: true
@Logeshwarsn
Copy link
Contributor

@dlundgren Thanks for reporting this issue. We have created a ticket internally to track this issue. We will update you once we fix this issue . Thanks !!

@bbaassssiiee
Copy link
Contributor

bbaassssiiee commented Jan 24, 2024

Debian default shell doesn't support the pipefail option, which is mandatory according to ansible-lint 1.

To resolve add this to your ansible.cfg:

[defaults]
executable = /bin/bash

dlundgren added a commit to dlundgren/JFrog-Cloud-Installers that referenced this issue Jan 26, 2024
@chukka chukka added the bug Something isn't working label Feb 2, 2024
@darthVikes
Copy link

darthVikes commented Feb 6, 2024

Believe I am having the same / similar issue:

TASK [jfrog.platform.artifactory : Check artifactory version] ********************************************************************************************************************************************************* task path: /opt/repo/provisioning/collections/ansible_collections/jfrog/platform/roles/artifactory/tasks/upgrade.yml:59 fatal: [server.domain.com]: FAILED! => {"changed": false, "cmd": "set -o pipefail;\ngrep artifactory.product.version \"/opt/jfrog/artifactory/app/artifactory.product.version.properties\" |cut -d= -f2\n", "delta": "0:00:00.005347", "end": "2024-02-06 14:41:13.110843", "msg": "non-zero return code", "rc": 2, "start": "2024-02-06 14:41:13.105496", "stderr": "grep: /opt/jfrog/artifactory/app/artifactory.product.version.properties: No such file or directory", "stderr_lines": ["grep: /opt/jfrog/artifactory/app/artifactory.product.version.properties: No such file or directory"], "stdout": "", "stdout_lines": []}

@darthVikes
Copy link

darthVikes commented Feb 6, 2024

That the above file isn't in
/opt/jfrog/artifactory/app/artifactory.product.version.properties

But in ;
/opt/jfrog/artifactory-pro-7.77.3/app/artifactory.product.version.properties

However artifactory home is set to :

jfrog_home_directory: /opt/jfrog
artifactory_home: "{{ jfrog_home_directory }}/artifactory"
artifactory_home: /opt/jfrog/artifactory ;

not :

artifactory_home: "{{ jfrog_home_directory }}/artifactory-{{ artifactory_flavour }}-{{ artifactory_version }}"
artifactory_home: /opt/jfrog/artifactory-pro-7.77.3

So not sure how this task is supposed to work?

  • name: Check artifactory version
    ansible.builtin.shell: |
    set -o pipefail;
    grep artifactory.product.version "{{ artifactory_home }}/app/artifactory.product.version.properties" |cut -d= -f2
    register: check_version_cmd
    changed_when: false

@darthVikes
Copy link

Is there a workaround?

@darthVikes
Copy link

There is this file that ansible did create on install with version info;

[root@server info]# cat installer-info.json

Ansible managed

{
"productId": "Ansible_Artifactory/10.17.0-7.19.4",
"features": [
{
"featureId": "Channel/galaxy"
}
]
}[root@server info]# pwd
/opt/jfrog/artifactory/var/etc/artifactory/info

@darthVikes
Copy link

darthVikes commented Feb 6, 2024

There is this file that annsible did create on install with version info;

[root@server info]# cat installer-info.json
#
# Ansible managed
#
{
  "productId": "Ansible_Artifactory/10.17.0-7.19.4",
  "features": [
    {
      "featureId": "Channel/galaxy"
    }
  ]
}[root@server info]# pwd
/opt/jfrog/artifactory/var/etc/artifactory/info

@darthVikes
Copy link

Above was from this task ;

./roles/artifactory/tasks/main.yml: line 144 - 150

  • name: Configure installer info
    become: true
    ansible.builtin.template:
    src: installer-info.json.j2
    dest: "{{ artifactory_home }}/var/etc/artifactory/info/installer-info.json"
    mode: 0644
    notify: Restart artifactory

@darthVikes
Copy link

darthVikes commented Feb 6, 2024

Can this file be used instead and updated with the installer-info.json.j2 or a template to keep it up to date when you upgrade?

Would you know ; @dlundgren ?

@dlundgren
Copy link
Contributor Author

Your issue is different as it's trying to locate a file that is in a different place from the default.

In your case, by setting artifactory_home: "{{ jfrog_home_directory }}/artifactory-{{ artifactory_flavour }}-{{ artifactory_version }}" you have a moving target, and it will never be able to find the currently installed file. This is due to the fact that artifactory_version changes with each release of the collection.

I would delete artifactory_home from where it was defined (host/group/global) outside of the collection, and then you'll have to manually move the /opt/jfrog/artifactory-pro-{{ installed_version }} to /opt/jfrog/artifactory. You may need to edit the configuration files to point them to the right path as well, I'm not sure. This will allow future upgrades to be easier.

@darthVikes
Copy link

darthVikes commented Feb 6, 2024

No, I am not setting it to :

artifactory_home: "{{ jfrog_home_directory }}/artifactory-{{ artifactory_flavour }}-{{ artifactory_version }}"

I have it set to the default: aka :

artifactory_home: "{{ jfrog_home_directory }}/artifactory"

However, that's where I found that specific file name.
aka under; /opt/jfrog/artifactory-pro-7.77.3/app/artifactory.product.version.properties

@darthVikes
Copy link

I mean why isn't it looking for :

name: Configure installer info
become: true
ansible.builtin.template:
src: installer-info.json.j2
dest: "{{ artifactory_home }}/var/etc/artifactory/info/installer-info.json"
mode: 0644
notify: Restart artifactory

vs what it is looking at?

name: Check artifactory version
ansible.builtin.shell: |
set -o pipefail;
grep artifactory.product.version "{{ artifactory_home }}/app/artifactory.product.version.properties" |cut -d= -f2
register: check_version_cmd
changed_when: false

@dlundgren
Copy link
Contributor Author

I can't answer why the role doesn't look at installer-info.json for the currently installed version, to me it makes sense to look at the actual app properties that are installed.

I can say that the /opt/jfrog/artifactory-pro-7.77.3 folder is where the Artifactory archive is untar'd to, before the app is moved to /opt/jfrog/artifactory.

This leads me to believe that your installation failed, or this collection/role wasn't used to install Artifactory, and it's installed manually in another folder.

At which point the upgrade tasks probably won't work properly, as /opt/jfrog/artifactory does not contain the actual application. I would try running the install process again so that Artifactory is in the correct location.

@darthVikes
Copy link

darthVikes commented Feb 7, 2024

True, I guess that is the answer, it makes more sense to look at the actual app properties.

Right ok, so it copies the extract into ./artifactory

[root@server jfrog]# pwd
/opt/jfrog
[root@server jfrog]# ll
total 2043884
drwxr-xr-x. 4 artifactory artifactory 157 Feb 2 16:50 artifactory
drwxr-xr-x 4 artifactory artifactory 28 May 21 2021 artifactory-pro-7.19.4
drwxr-xr-x 4 artifactory artifactory 28 Jan 23 15:44 artifactory-pro-7.77.3
-rw-r--r-- 1 artifactory artifactory 497144409 Feb 1 15:31 jfrog-artifactory-pro-7.19.4-linux.tar.gz
-rw-r--r-- 1 artifactory artifactory 1595786359 Feb 6 13:45 jfrog-artifactory-pro-7.77.3-linux.tar.gz

I see that now with this task.

  • name: Copy untar directory to artifactory home
    become: true
    ansible.builtin.copy:
    src: "{{ artifactory_untar_home }}/"
    dest: "{{ artifactory_home }}"
    owner: "{{ artifactory_user }}"
    group: "{{ artifactory_group }}"
    mode: 0755
    remote_src: true
    when: not app_dir_check.stat.exists

and there are folders/files in there:

cd /opt/jfrog/artifactory/app
[root@server app]# ll
total 4
drwxr-xr-x 3 artifactory artifactory 20 May 21 2021 artifactory
drwxr-xr-x 3 artifactory artifactory 4096 Feb 2 16:37 bin
drwxr-xr-x 2 artifactory artifactory 225 Feb 1 15:32 doc
drwxr-xr-x 3 artifactory artifactory 17 May 21 2021 event
drwxr-xr-x 3 artifactory artifactory 17 Feb 2 21:46 frontend
drwxr-xr-x 3 artifactory artifactory 17 May 21 2021 metadata
drwxr-xr-x 6 artifactory artifactory 95 Feb 1 15:31 misc
drwxr-xr-x 4 artifactory artifactory 28 May 21 2021 replicator
drwxr-xr-x 3 artifactory artifactory 17 May 21 2021 router
drwxr-xr-x 2 artifactory artifactory 6 Feb 6 13:46 run
drwxr-xr-x 8 artifactory artifactory 88 May 21 2021 third-party

but not this file which is strange; artifactory.product.version.properties

/opt/jfrog/artifactory-pro-7.77.3/app
[root@server app]# ll
total 12
drwxr-xr-x 3 artifactory artifactory 20 Jan 23 15:44 artifactory
-rwxr-xr-x 1 artifactory artifactory 174 Jan 23 15:18 artifactory.product.version.properties
drwxr-xr-x 3 artifactory artifactory 4096 Feb 6 13:46 bin
drwxr-xr-x 2 artifactory artifactory 4096 Feb 6 13:46 doc
drwxr-xr-x 3 artifactory artifactory 17 Jan 23 15:44 event
drwxr-xr-x 3 artifactory artifactory 17 Jan 23 15:44 frontend
drwxr-xr-x 3 artifactory artifactory 17 Jan 23 15:21 jfconnect
drwxr-xr-x 3 artifactory artifactory 17 Jan 23 15:44 metadata
drwxr-xr-x 6 artifactory artifactory 95 Feb 6 13:46 misc
drwxr-xr-x 3 artifactory artifactory 17 Jan 23 15:44 observability
drwxr-xr-x 3 artifactory artifactory 17 Jan 23 15:21 replicator
drwxr-xr-x 3 artifactory artifactory 17 Jan 23 15:44 router
drwxr-xr-x 4 artifactory artifactory 28 Jan 23 15:44 rtfs
drwxr-xr-x 8 artifactory artifactory 88 Jan 23 15:44 third-party

OOOOH. well, this may answer the above question;

I installed 7.19.4 as that was the current version that we are running on another host. I'm taking the MySQL db and exporting it, importing it into this new server, and doing a rsync of the filestore over to the new box also. I was thinking it would be better to do the same version for that first migration, then I would upgrade the version which is why you see the 2 versions above. However, the first version which is what I used for the initial install does not have the artifactory.product.version.properties as part of the *.tar extract. So I wonder when that got added. And If I could copy just that file in then? Or should I just install the latest version instead of trying to install the old version first and then upgrading?

[root@server app]# pwd
/opt/jfrog/artifactory-pro-7.19.4/app
[root@server app]# ls -al
total 4
drwxr-xr-x 12 artifactory artifactory 155 Feb 1 15:32 .
drwxr-xr-x 4 artifactory artifactory 28 May 21 2021 ..
drwxr-xr-x 3 artifactory artifactory 20 May 21 2021 artifactory
drwxr-xr-x 3 artifactory artifactory 4096 Feb 1 15:31 bin
drwxr-xr-x 2 artifactory artifactory 225 Feb 1 15:32 doc
drwxr-xr-x 3 artifactory artifactory 17 May 21 2021 event
drwxr-xr-x 3 artifactory artifactory 17 May 21 2021 frontend
drwxr-xr-x 3 artifactory artifactory 17 May 21 2021 metadata
drwxr-xr-x 6 artifactory artifactory 95 Feb 1 15:31 misc
drwxr-xr-x 4 artifactory artifactory 28 May 21 2021 replicator
drwxr-xr-x 3 artifactory artifactory 17 May 21 2021 router
drwxr-xr-x 8 artifactory artifactory 88 May 21 2021 third-party

@darthVikes
Copy link

Seems like a lot of work to go back to every previous release to make sure that file is there. A quicker option is if that file is not there perhaps look for the installer-info.json file that was created with older versions.

I was able to work around the issue by copying the artifactory.product.version.properties file from the newer build and then editing it to contain the older version information.

@darthVikes
Copy link

Moving what I found to a new issue.

chukka added a commit that referenced this issue Mar 1, 2024
* #365 Use `fetch` and `lookup('ini')` to get the version (#369)

* [ansible] JFrog Platform 10.17.1 release

---------

Co-authored-by: David Lundgren <[email protected]>
@chukka
Copy link
Collaborator

chukka commented Mar 1, 2024

Fixed via #375

@chukka chukka closed this as completed Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants