Skip to content

Commit

Permalink
common: Fix lint on jinja computations
Browse files Browse the repository at this point in the history
  • Loading branch information
jocelynj committed Dec 29, 2023
1 parent 57f847f commit 288a1f2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
4 changes: 0 additions & 4 deletions .config/ansible-lint-ignore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,12 @@ roles/common/tasks/main.yml deprecated-local-action
roles/common/tasks/main.yml deprecated-module
roles/common/tasks/main.yml fqcn[action-core]
roles/common/tasks/main.yml fqcn[action]
roles/common/tasks/main.yml jinja[spacing]
roles/common/tasks/main.yml name[casing]
roles/common/tasks/main.yml name[missing]
roles/common/tasks/main.yml no-changed-when
roles/common/tasks/main.yml no-handler
roles/common/tasks/main.yml risky-shell-pipe
roles/common/tasks/munin-node.yml fqcn[action-core]
roles/common/tasks/munin-node.yml jinja[spacing]
roles/common/tasks/munin-node.yml name[casing]
roles/common/tasks/munin-node.yml no-changed-when
roles/common/tasks/nginx.yml fqcn[action-core]
Expand All @@ -102,13 +100,11 @@ roles/common/tasks/ntp.yml name[casing]
roles/common/tasks/ssh-tunnel.yml command-instead-of-shell
roles/common/tasks/ssh-tunnel.yml fqcn[action-core]
roles/common/tasks/ssh-tunnel.yml fqcn[action]
roles/common/tasks/ssh-tunnel.yml jinja[spacing]
roles/common/tasks/ssh-tunnel.yml name[casing]
roles/common/tasks/ssh-tunnel.yml name[missing]
roles/common/tasks/ssh-tunnel.yml no-handler
roles/common/tasks/sysctl.yml fqcn[action-core]
roles/common/tasks/sysctl.yml fqcn[action]
roles/common/tasks/sysctl.yml jinja[spacing]
roles/common/tasks/sysctl.yml name[casing]
roles/common/tasks/sysstat.yml fqcn[action-core]
roles/common/tasks/sysstat.yml name[casing]
Expand Down
1 change: 1 addition & 0 deletions .config/ansible-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ profile: production

enable_list:
- empty-string-compare
- jinja
- no-free-form
- no-log-password
- no-prompting
Expand Down
16 changes: 8 additions & 8 deletions roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- name: set proxmox password
set_fact:
proxmox_password: "{{ lookup('env','PROXMOX_PASSWORD_'+proxmox_var.host.split('.')[0]) }}"
proxmox_password: "{{ lookup('env', 'PROXMOX_PASSWORD_' + proxmox_var.host.split('.')[0]) }}"
when: proxmox_var is defined and vm_host is defined and lookup('env','PROXMOX_PASSWORD_'+proxmox_var.host.split('.')[0])

- name: init cache/templates/
Expand Down Expand Up @@ -71,7 +71,7 @@
onboot: yes
ostemplate: "local:vztmpl/{{ proxmox_var.ostemplate }}"
password: "{{ lookup('password', 'credentials/proxmox/' + inventory_hostname) }}"
pubkey: "{{ lookup('file', lookup('env','PROXMOX_SSHPUBKEY')) }}"
pubkey: "{{ lookup('file', lookup('env', 'PROXMOX_SSHPUBKEY')) }}"
state: present
storage: "{{ proxmox_var.storage }}"
swap: "{{ proxmox_var.swap }}"
Expand Down Expand Up @@ -113,7 +113,7 @@
ostype: "l26"
scsi:
scsi0: "{{ proxmox_var.storage }}:{{ proxmox_var.disk }},format=raw"
sshkeys: "{{ lookup('file', lookup('env','PROXMOX_SSHPUBKEY')) }}"
sshkeys: "{{ lookup('file', lookup('env', 'PROXMOX_SSHPUBKEY')) }}"
state: present
when: proxmox_password is defined and (proxmox_var.kvm is defined and proxmox_var.kvm == 1)
register: create_vm
Expand All @@ -139,7 +139,7 @@
ostype: "l26"
scsi:
scsi0: "{{ proxmox_var.storage }}:{{ proxmox_var.disk }},format=raw"
sshkeys: "{{ lookup('file', lookup('env','PROXMOX_SSHPUBKEY')) }}"
sshkeys: "{{ lookup('file', lookup('env', 'PROXMOX_SSHPUBKEY')) }}"
state: present
update: yes
when: proxmox_password is defined and (proxmox_var.kvm is defined and proxmox_var.kvm == 1)
Expand Down Expand Up @@ -232,7 +232,7 @@
block: |
Host {{ item }}
Hostname {{ hostvars[item].proxmox_var.ipv6 }}
with_items: '{{play_hosts}}'
with_items: '{{ play_hosts }}'
when: proxmox_password is defined and (create_ct.changed or create_vm.changed)
become: no

Expand All @@ -242,7 +242,7 @@
module: known_hosts
name: "{{ hostvars[item].proxmox_var.ipv6 }}"
key: "{{ lookup('pipe', 'ssh-keyscan {{ hostvars[item].proxmox_var.ipv6 }}') }}"
with_items: '{{play_hosts}}'
with_items: '{{ play_hosts }}'
when: proxmox_password is defined and (create_ct.changed or create_vm.changed)
become: no

Expand Down Expand Up @@ -491,9 +491,9 @@
- name: add ssh key to user backuppc
authorized_key:
user: backuppc
key: "{{ lookup('file',item) }}"
key: "{{ lookup('file', item) }}"
with_fileglob:
- "{{ lookup('env','PWD') }}/public_keys/backuppc-*"
- "{{ lookup('env', 'PWD') }}/public_keys/backuppc-*"

- name: create empty /var/www for backuppc
file:
Expand Down
2 changes: 1 addition & 1 deletion roles/common/tasks/munin-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
dest: /etc/munin/munin-node.conf
regexp: "^host_name {{ inventory_hostname }}"
insertafter: "^#host_name"
line: "host_name {{ inventory_hostname }}"
line: "host_name {{ inventory_hostname }}"
notify:
- restart munin-node

Expand Down
4 changes: 2 additions & 2 deletions roles/common/tasks/ssh-tunnel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@
tags: ssh-tunnel
when: ansible_hostname == 'osm7'
with_fileglob:
- "{{ lookup('env','PWD') }}/public_keys/ansible/{{ user }}-osm3"
- "{{ lookup('env','PWD') }}/public_keys/ansible/{{ user }}-osm101"
- "{{ lookup('env', 'PWD') }}/public_keys/ansible/{{ user }}-osm3"
- "{{ lookup('env', 'PWD') }}/public_keys/ansible/{{ user }}-osm101"
2 changes: 1 addition & 1 deletion roles/common/tasks/sysctl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@
- name: Allow 2MB huge pages up to 60% of the RAM
sysctl:
name: vm.nr_overcommit_hugepages
value: "{{ ( ansible_memtotal_mb * 0.6 / 2)|int }}"
value: "{{ (ansible_memtotal_mb * 0.6 / 2) | int }}"
sysctl_file: /etc/sysctl.d/ansible.conf

0 comments on commit 288a1f2

Please sign in to comment.