Skip to content

Commit

Permalink
Résout les avertissements de ansible-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
philippemilink committed Oct 20, 2023
1 parent 16e77af commit dbe2e07
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
exclude_paths:
- .github/
skip_list:
- name[casing]
- var-naming[no-role-prefix]
8 changes: 8 additions & 0 deletions collections/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
collections:
- name: community.general
version: 7.5.0
- name: community.mysql
version: 3.7.2
- name: ansible.posix
version: 1.5.4
3 changes: 2 additions & 1 deletion playbook.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- hosts: app
- name: deploy zds-site
hosts: app
become: true
roles:
- role: common
Expand Down
1 change: 1 addition & 0 deletions roles/app/tasks/fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- name: install requirements in virtualenv to load fixtures
become: true
become_user: "{{ appuser }}"
ansible.builtin.pip:
requirements: "{{ appdir }}/requirements-dev.txt"
Expand Down
21 changes: 17 additions & 4 deletions roles/app/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

# User, directories, files and symlink creation

- name: should have a {{ appuser }} user
- name: should have a user named {{ appuser }}
ansible.builtin.user:
name: "{{ appuser }}"
shell: /bin/false
Expand Down Expand Up @@ -60,6 +60,7 @@
- bootstrap

- name: checkout the application
become: true
become_user: "{{ appuser }}"
vars:
refspec: "{{ '+refs/pull/*:refs/pull/*' if 'pull/' in appversion else '+refs/heads/*:refs/remotes/origin/*' }}"
Expand Down Expand Up @@ -176,6 +177,7 @@
# Installation of backend, frontend and zmd dependencies

- name: update pip in virtualenv # some dependencies (like rust ones) require a recent pip
become: true
become_user: "{{ appuser }}"
ansible.builtin.pip:
name:
Expand All @@ -187,6 +189,7 @@
- bootstrap

- name: install wheel and sqlparse in virtualenv
become: true
become_user: "{{ appuser }}"
ansible.builtin.pip:
name:
Expand All @@ -198,6 +201,7 @@
- bootstrap

- name: install requirements in virtualenv
become: true
become_user: "{{ appuser }}"
ansible.builtin.pip:
requirements: "{{ appdir }}/requirements-prod.txt"
Expand All @@ -208,13 +212,14 @@
- upgrade

- name: include nodejs installation
include_role:
ansible.builtin.include_role:
name: common
tasks_from: nodejs
tags:
- bootstrap

- name: install frontend # noqa no-changed-when
become: true
become_user: "{{ appuser }}"
ansible.builtin.command: yarn install --frozen-lockfile
args:
Expand All @@ -224,6 +229,7 @@
- upgrade

- name: install zmarkdown
become: true
become_user: "{{ appuser }}"
community.general.npm:
path: "{{ zmarkdown_dir }}"
Expand All @@ -235,6 +241,7 @@
# Frontend building

- name: build frontend # noqa no-changed-when
become: true
become_user: "{{ appuser }}"
ansible.builtin.command: npm run build
args:
Expand All @@ -244,6 +251,7 @@
- upgrade

- name: collect static files
become: true
become_user: "{{ appuser }}"
environment:
DJANGO_SETTINGS_MODULE: "zds.settings.{{ env }}"
Expand All @@ -260,6 +268,7 @@
# Start of maintenance, if needed

- name: check if database migration is needed
become: true
become_user: "{{ appuser }}"
environment:
DJANGO_SETTINGS_MODULE: "zds.settings.{{ env }}"
Expand All @@ -284,6 +293,7 @@
- upgrade

- name: migrate database
become: true
become_user: "{{ appuser }}"
environment:
DJANGO_SETTINGS_MODULE: "zds.settings.{{ env }}"
Expand All @@ -298,6 +308,7 @@
- upgrade

- name: clear cache
become: true
become_user: "{{ appuser }}"
environment:
DJANGO_SETTINGS_MODULE: "zds.settings.{{ env }}"
Expand Down Expand Up @@ -373,12 +384,14 @@
- bootstrap
- upgrade

- include_tasks: fixtures.yml
- name: load fixtures
ansible.builtin.include_tasks: fixtures.yml
when: load_fixtures
tags:
- bootstrap

- include_tasks: geodata.yml
- name: setup geodata
ansible.builtin.include_tasks: geodata.yml
when: secrets.geolite.license_key is defined
tags:
- bootstrap
Expand Down
2 changes: 1 addition & 1 deletion roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
src: "{{ item.src }}"
dest: "/etc/zsh/{{ item.path }}"
mode: u=rw,g=r,o=r
with_filetree: zsh/
with_community.general.filetree: zsh/
when: item.state == 'file'

- name: ensure the system can use the HTTPS transport for APT
Expand Down
2 changes: 1 addition & 1 deletion roles/firewall/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

- name: Log firewall only in /var/log/ufw.log
# otherwise /var/log/{kern.log,messages,syslog} get full of [UFW BLOCK] messages
lineinfile:
ansible.builtin.lineinfile:
path: /etc/rsyslog.d/20-ufw.conf
search_string: "#& stop"
line: "& stop"
Expand Down
4 changes: 2 additions & 2 deletions roles/latex/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- name: run texhash
- name: run texhash # noqa no-changed-when
become: true
become_user: "{{ appuser }}"
ansible.builtin.shell: texhash $HOME/texmf

- name: refresh font-config cache
- name: refresh font-config cache # noqa no-changed-when
ansible.builtin.command: fc-cache -f
8 changes: 5 additions & 3 deletions roles/latex/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@
- bootstrap

- name: install pygments
pip:
ansible.builtin.pip:
name: Pygments
executable: pip3
tags:
- bootstrap

- include_tasks: packages.yml
- name: install latex packages
ansible.builtin.include_tasks: packages.yml
tags:
- bootstrap

- name: clone the template # noqa git-latest
- name: clone the template # noqa latest[git]
become: true
become_user: "{{ appuser }}"
ansible.builtin.git:
Expand All @@ -52,6 +53,7 @@
ansible.builtin.get_url:
url: "{{ item[0].url }}/{{ item[1].ext | upper }}/{{ item[0].name }}-{{ item[2] }}.{{ item[1].ext }}"
dest: /usr/local/share/fonts/{{ item[1].path }}/{{ item[0].slug }}/{{ item[0].name }}-{{ item[2] }}.{{ item[1].ext }}
mode: u=rw,g=r,o=r
with_nested:
- "{{ fonts }}"
- "{{ fonttypes }}"
Expand Down
6 changes: 4 additions & 2 deletions roles/latex/tasks/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
- bootstrap

- name: check ansible state
ansible.builtin.slurp: src=/opt/zds/texmf/ansible-state
ansible.builtin.slurp:
src: /opt/zds/texmf/ansible-state
register: installed_packages

- name: install packages # noqa risky-shell-pipe
- name: install packages # noqa risky-shell-pipe no-changed-when
become: true
become_user: "{{ appuser }}"
ansible.builtin.shell: >
Expand Down Expand Up @@ -53,5 +54,6 @@
ansible.builtin.get_url:
url: https://raw.githubusercontent.com/tabu-issues-for-future-maintainer/tabu/master/tabu.sty
dest: /opt/zds/texmf/tex/latex/tabu/tabu.sty
mode: u=rw,g=r,o=r
tags:
- bootstrap
2 changes: 1 addition & 1 deletion roles/mysql/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
enabled: true

- name: install MySQLdb-python
pip:
ansible.builtin.pip:
name: mysqlclient
executable: pip3

Expand Down
2 changes: 1 addition & 1 deletion roles/web/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
src: "{{ item.src }}"
dest: "/etc/nginx/{{ item.path }}"
mode: u=rw,g=r,o=r
with_filetree: nginx/
with_community.general.filetree: nginx/
when: item.state == 'file'
notify: reload nginx

Expand Down

0 comments on commit dbe2e07

Please sign in to comment.