Skip to content

Commit

Permalink
Remove warn argument from command and shell module
Browse files Browse the repository at this point in the history
The `warn` argument to the command and shell modules was deprecated in
Ansible 2.11 and removed in 2.14. This argument is no longer needed as
no warnings are issued anymore if these modules are used in ways which
could be replaced by an Ansible module.

See ansible/ansible#70504.

(cherry-picked from commit a2a6555)
  • Loading branch information
gaudenz authored and urscale committed May 28, 2024
1 parent 053c3bf commit f246072
Show file tree
Hide file tree
Showing 5 changed files with 545 additions and 0 deletions.
125 changes: 125 additions & 0 deletions ansible/roles/gitlab/tasks/configure_gitaly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
# Copyright (C) 2015-2017 Maciej Delmanowski <[email protected]>
# Copyright (C) 2015-2017 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-only

# gitaly is checked out based on tags instead of branches, and since we
# cannot work with tags from a bare repository, we need to work around it
# a little.

- name: Check if bare repository is cloned
stat:
path: '{{ gitlab__gitaly_dest }}'
register: gitlab_register_gitaly_cloned

- name: Save current checkout hash for update
command: git rev-parse HEAD
args:
chdir: '{{ gitlab__gitaly_dest }}'
register: gitlab_register_gitaly_current_head
changed_when: False
become: True
become_user: '{{ gitlab_user }}'
when: gitlab_register_gitaly_cloned.stat.exists

- name: Change current HEAD to master in bare repository for update
command: git symbolic-ref HEAD refs/heads/master
args:
chdir: '{{ gitlab__gitaly_dest }}'
changed_when: False
become: True
become_user: '{{ gitlab_user }}'
when: gitlab_register_gitaly_cloned.stat.exists

- name: Clone gitaly source code
git:
repo: '{{ gitlab__gitaly_repo }}'
dest: '{{ gitlab__gitaly_dest }}'
version: 'master'
bare: True
update: True
become: True
become_user: '{{ gitlab_user }}'

- name: Restore HEAD to previous checkout
copy:
content: '{{ gitlab_register_gitaly_current_head.stdout }}'
dest: '{{ gitlab__gitaly_dest + "/HEAD" }}'
owner: '{{ gitlab_user }}'
group: '{{ gitlab_group }}'
mode: '0644'
changed_when: False
when: gitlab_register_gitaly_cloned.stat.exists

- name: Create gitaly checkout directory
file:
path: '{{ gitlab__gitaly_checkout }}'
state: 'directory'
owner: '{{ gitlab_user }}'
group: '{{ gitlab_group }}'
mode: '0755'

- name: Prepare gitaly worktree
copy:
content: 'gitdir: {{ gitlab__gitaly_dest }}'
dest: '{{ gitlab__gitaly_checkout + "/.git" }}'
owner: '{{ gitlab_user }}'
group: '{{ gitlab_group }}'
mode: '0644'

- name: Get currently checked out git tag
command: git describe --tags
environment:
GIT_WORK_TREE: '{{ gitlab__gitaly_checkout }}'
args:
chdir: '{{ gitlab__gitaly_dest }}'
become: True
become_user: '{{ gitlab_user }}'
register: gitlab_register_gitaly_target_tag
changed_when: gitlab_register_gitaly_target_tag.stdout != gitlab__fact_version.gitaly

- name: Checkout gitaly
command: git checkout -f {{ gitlab__fact_version.gitaly }}
environment:
GIT_WORK_TREE: '{{ gitlab__gitaly_checkout }}'
args:
chdir: '{{ gitlab__gitaly_dest }}'
become: True
become_user: '{{ gitlab_user }}'
register: gitlab_register_gitlab__gitaly_checkout
when: (gitlab__fact_version.gitaly != gitlab_register_gitaly_target_tag.stdout) or
not gitlab_register_gitaly_cloned.stat.exists

- name: Stop gitaly service for an upgrade
service: # noqa no-handler
name: 'gitlab-gitaly.service'
state: 'stopped'
when: (ansible_local|d() and ansible_local.gitlab|d() and
(ansible_local.gitlab.installed|d() | bool) and
ansible_service_mgr == 'systemd' and
gitlab_register_gitlab__gitaly_checkout is changed)

- name: Setup gitaly
make: # noqa no-handler
chdir: '{{ gitlab__gitaly_checkout }}'
become: True
become_user: '{{ gitlab_user }}'
when: gitlab_register_gitlab__gitaly_checkout is changed

- name: Start gitaly service after an upgrade
service: # noqa no-handler
name: 'gitlab-gitaly.service'
state: 'started'
when: (ansible_local|d() and ansible_local.gitlab|d() and
(ansible_local.gitlab.installed|d() | bool) and
ansible_service_mgr == 'systemd' and
gitlab_register_gitlab__gitaly_checkout is changed)

- name: Configure Gitaly
template:
src: 'var/local/git/gitaly/config.toml.j2'
dest: '{{ gitlab__gitaly_checkout + "/config.toml" }}'
owner: '{{ gitlab_user }}'
group: '{{ gitlab_group }}'
mode: '0644'
notify: 'Restart gitaly'
118 changes: 118 additions & 0 deletions ansible/roles/gitlab/tasks/configure_gitlab-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
# Copyright (C) 2015-2017 Maciej Delmanowski <[email protected]>
# Copyright (C) 2015-2017 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-only

# gitlab-pages checked out based on tags instead of branches, and since we
# cannot work with tags from a bare repository, we need to work around it
# a little.

- name: Check if bare repository is cloned
stat:
path: '{{ gitlab_pages_dest }}'
register: gitlab_register_pages_cloned

- name: Save current checkout hash for update
command: git rev-parse HEAD
args:
chdir: '{{ gitlab_pages_dest }}'
register: gitlab_register_pages_current_head
changed_when: False
become: True
become_user: '{{ gitlab_user }}'
when: gitlab_register_pages_cloned.stat|d() and
gitlab_register_pages_cloned.stat.exists

- name: Change current HEAD to master in bare repository for update
command: git symbolic-ref HEAD refs/heads/master
args:
chdir: '{{ gitlab_pages_dest }}'
changed_when: False
become: True
become_user: '{{ gitlab_user }}'
when: gitlab_register_pages_cloned.stat|d() and
gitlab_register_pages_cloned.stat.exists

- name: Clone gitlab-pages source code
git:
repo: '{{ gitlab_pages_repo }}'
dest: '{{ gitlab_pages_dest }}'
version: 'master'
bare: True
update: True
become: True
become_user: '{{ gitlab_user }}'

- name: Restore HEAD to previous checkout
copy:
content: '{{ gitlab_register_pages_current_head.stdout }}'
dest: '{{ gitlab_pages_dest + "/HEAD" }}'
owner: '{{ gitlab_user }}'
group: '{{ gitlab_group }}'
mode: '0644'
changed_when: False
when: gitlab_register_pages_cloned.stat|d() and
gitlab_register_pages_cloned.stat.exists

- name: Check if gitlab-pages is checked out
stat:
path: '{{ gitlab_pages_checkout }}'
register: gitlab_register_pages_directory

- name: Create gitlab-pages checkout directory
file:
path: '{{ gitlab_pages_checkout }}'
state: 'directory'
owner: '{{ gitlab_user }}'
group: '{{ gitlab_group }}'
mode: '0755'

- name: Prepare gitlab-pages worktree
copy:
content: 'gitdir: {{ gitlab_pages_dest }}'
dest: '{{ gitlab_pages_checkout + "/.git" }}'
owner: '{{ gitlab_user }}'
group: '{{ gitlab_group }}'
mode: '0644'

- name: Get currently checked out git tag
command: git describe --tags
environment:
GIT_WORK_TREE: '{{ gitlab_pages_checkout }}'
args:
chdir: '{{ gitlab_pages_dest }}'
become: True
become_user: '{{ gitlab_user }}'
register: gitlab_register_pages_target_tag
changed_when: gitlab_register_pages_target_tag.stdout != gitlab__fact_version.pages

- name: Checkout gitlab-pages
command: git checkout -f {{ gitlab__fact_version.pages }}
environment:
GIT_WORK_TREE: '{{ gitlab_pages_checkout }}'
args:
chdir: '{{ gitlab_pages_dest }}'
become: True
become_user: '{{ gitlab_user }}'
register: gitlab_register_pages_checkout
when: (gitlab__fact_version.pages|d() != gitlab_register_pages_target_tag.stdout|d()) or
(gitlab_register_pages_cloned.stat|d() and not gitlab_register_pages_cloned.stat.exists)

- name: Setup gitlab-pages
make: # noqa no-handler
chdir: '{{ gitlab_pages_checkout }}'
environment:
GOPATH: '{{ gitlab_app_root_path }}/go'
become: True
become_user: '{{ gitlab_user }}'
when: gitlab_register_pages_checkout is changed

- name: Setup GitLab Pages default variables
template:
src: 'etc/default/gitlab-pages.j2'
dest: '/etc/default/gitlab-pages'
owner: 'root'
group: '{{ gitlab_group }}'
mode: '0640'
when: gitlab_version is version_compare("12.8", operator="ge", strict=True)
notify: [ 'Restart gitlab', 'Restart gitlab.slice' ]
122 changes: 122 additions & 0 deletions ansible/roles/gitlab/tasks/configure_gitlab-shell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---
# Copyright (C) 2015-2017 Maciej Delmanowski <[email protected]>
# Copyright (C) 2015-2017 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-only

# gitlab-shell is checked out based on tags instead of branches, and since we
# cannot work with tags from a bare repository, we need to work around it
# a little.

- name: Check if bare repository is cloned
stat:
path: '{{ gitlab_shell_git_dest }}'
register: gitlab_register_shell_cloned

- name: Save current checkout hash for update
command: git rev-parse HEAD
args:
chdir: '{{ gitlab_shell_git_dest }}'
register: gitlab_register_shell_current_head
changed_when: False
become: True
become_user: '{{ gitlab_user }}'
when: gitlab_register_shell_cloned.stat.exists

- name: Change current HEAD to master in bare repository for update
command: git symbolic-ref HEAD refs/heads/master
args:
chdir: '{{ gitlab_shell_git_dest }}'
changed_when: False
become: True
become_user: '{{ gitlab_user }}'
when: gitlab_register_shell_cloned.stat.exists

- name: Create GitLab source directory
file:
path: '{{ gitlab_src_path }}'
state: 'directory'
owner: '{{ gitlab_user }}'
group: '{{ gitlab_group }}'
mode: '0750'

- name: Clone gitlab-shell source code
git:
repo: '{{ gitlab_shell_git_repo }}'
dest: '{{ gitlab_shell_git_dest }}'
version: 'master'
bare: True
update: True
become: True
become_user: '{{ gitlab_user }}'

- name: Restore HEAD to previous checkout
copy:
content: '{{ gitlab_register_shell_current_head.stdout }}'
dest: '{{ gitlab_shell_git_dest + "/HEAD" }}'
owner: '{{ gitlab_user }}'
group: '{{ gitlab_group }}'
mode: '0644'
changed_when: False
when: gitlab_register_shell_cloned.stat.exists

- name: Create gitlab-shell checkout directory
file:
path: '{{ gitlab_shell_git_checkout }}'
state: 'directory'
owner: '{{ gitlab_user }}'
group: '{{ gitlab_group }}'
mode: '0755'

- name: Prepare gitlab-shell worktree
copy:
content: 'gitdir: {{ gitlab_shell_git_dest }}'
dest: '{{ gitlab_shell_git_checkout + "/.git" }}'
owner: '{{ gitlab_user }}'
group: '{{ gitlab_group }}'
mode: '0644'

- name: Get currently checked out git tag
command: git describe --tags
environment:
GIT_WORK_TREE: '{{ gitlab_shell_git_checkout }}'
args:
chdir: '{{ gitlab_shell_git_dest }}'
become: True
become_user: '{{ gitlab_user }}'
register: gitlab_register_shell_target_tag
changed_when: gitlab_register_shell_target_tag.stdout != gitlab__fact_version.shell

- name: Checkout gitlab-shell
command: git checkout --force {{ gitlab__fact_version.shell }}
environment:
GIT_WORK_TREE: '{{ gitlab_shell_git_checkout }}'
args:
chdir: '{{ gitlab_shell_git_dest }}'
become: True
become_user: '{{ gitlab_user }}'
register: gitlab_register_shell_checkout
when: ((gitlab__fact_version.shell != gitlab_register_shell_target_tag.stdout) or
not gitlab_register_shell_cloned.stat.exists | bool)

- name: Configure gitlab-shell
template:
src: 'var/local/git/gitlab-shell/config.yml.j2'
dest: '{{ gitlab_shell_git_checkout + "/config.yml" }}'
owner: '{{ gitlab_user }}'
group: '{{ gitlab_group }}'
mode: '0640'

- name: Create GitLab data root directories
file:
path: '{{ item }}'
state: 'directory'
owner: '{{ gitlab_user }}'
group: '{{ gitlab_group }}'
mode: '0750'
with_items: [ '{{ gitlab_repositories_path }}', '{{ gitlab_satellites_path }}' ]

- name: Setup gitlab-shell
shell: ./bin/install ; make compile
args: # noqa no-handler
chdir: '{{ gitlab_shell_git_checkout }}'
when: gitlab_register_shell_checkout is changed
Loading

0 comments on commit f246072

Please sign in to comment.