Skip to content

Commit

Permalink
Add ability to generate bootstrap admin token (#432)
Browse files Browse the repository at this point in the history
Co-authored-by: Robin Duhan <[email protected]>
  • Loading branch information
2 people authored and chukka committed Feb 14, 2025
1 parent fdaf57d commit 90f97ac
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ artifactory_allowNonPostgresql: false
# Default username and password, uncomment and change to manage with ansible
# artifactory_admin_username: admin
# artifactory_admin_password: password
# Set this to true to generate a bootstrap admin token - https://jfrog.com/help/r/jfrog-installation-setup-documentation/create-an-automatic-admin-token
artifactory_generate_bootstrap_token: false
artifactory_service_file: /lib/systemd/system/artifactory.service
# Provide systemyaml content below with 2-space indentation
artifactory_systemyaml: |-
Expand Down Expand Up @@ -93,10 +95,10 @@ artifactory_binarystore: |-
artifactory_systemyaml_override: false
# Allow artifactory user to create crontab rules
artifactory_allow_crontab: false
# Provide access config patch content
artifactory_access_config_patch: ""
# Provide access config patch content
artifactory_access_config_patch: |-
# security:
# authentication:
# mtls:
# enabled: true
# enabled: true
# extraction-regex: (.*)
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
- "{{ artifactory_home }}/var/etc"
- "{{ artifactory_home }}/var/etc/security/"
- "{{ artifactory_home }}/var/etc/artifactory/info/"
- "{{ artifactory_home }}/var/bootstrap/etc/access/keys"

- name: Check if system.yaml exists
become: true
Expand Down Expand Up @@ -172,19 +173,31 @@
- artifactory_licenses | length > 0
notify: Restart artifactory

- name: Set up Artifactory admin account
- name: Set up Artifactory admin account
become: true
ansible.builtin.template:
src: bootstrap.creds.j2
dest: "{{ artifactory_home }}/var/etc/access/bootstrap.creds"
owner: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
mode: 0600
when:
when:
- artifactory_admin_username is defined
- artifactory_admin_password is defined
notify: Restart artifactory

- name: Generate Artifactory bootstrap admin token
become: true
ansible.builtin.file:
path: "{{ artifactory_home }}/var/bootstrap/etc/access/keys/generate.token.json"
state: touch
owner: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
mode: 0600
when:
- artifactory_generate_bootstrap_token | bool
notify: Restart artifactory

- name: Check if included database driver is the correct version
become: true
ansible.builtin.stat:
Expand Down Expand Up @@ -239,4 +252,4 @@
delay: 5
when:
- not ansible_check_mode
- artifactory_start_service | bool
- artifactory_start_service | bool

0 comments on commit 90f97ac

Please sign in to comment.