Skip to content

Commit

Permalink
fix some lint offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Oct 20, 2023
1 parent 7ba3c0d commit a35fee7
Show file tree
Hide file tree
Showing 23 changed files with 105 additions and 48 deletions.
1 change: 0 additions & 1 deletion .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ skip_list:
- git-latest # Git checkouts must contain explicit version
- meta-no-info # meta/main.yml should contain relevant info
- no-changed-when # Commands should not change things if nothing needs doing
- no-handler # Tasks that run when changed should likely be handlers
- package-latest # Package installs should not use latest
- jinja[spacing]
- role-name[path]
Expand Down
4 changes: 2 additions & 2 deletions roles/bats/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
state: "directory"
path: "{{ bats_output_dir }}"

- block:
- when: bats_run
block:
- name: "Run bats"
shell: "bats --trace --tap {{ item }} > {{ bats_output_dir }}/{{ item }}.tap"
args:
Expand Down Expand Up @@ -64,4 +65,3 @@
msg: "Test failed, please see {{ bats_output_dir }}/ for more information"
when: item.rc != 0
with_items: "{{ test_output.results }}"
when: bats_run
2 changes: 1 addition & 1 deletion roles/custom_certificates/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
args:
creates: "{{ custom_certificates_ca_directory_certs }}/{{ custom_certificates_server }}.crt"

- include: issue.yml
- include_tasks: issue.yml
when: custom_certificates_hostnames is defined
with_items: "{{ custom_certificates_hostnames }}"
loop_control:
Expand Down
9 changes: 7 additions & 2 deletions roles/dynflow_devel/tasks/dynflow_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
state: present

- name: 'Install bundler'
gem: name=bundler state=present
gem:
name: bundler
state: present

- name: 'Install gems'
bundler: chdir=~/dynflow state=present executable=~/bin/bundle
bundler:
chdir: '~/dynflow'
state: present
executable: '~/bin/bundle'
4 changes: 2 additions & 2 deletions roles/foreman_installer/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
when: foreman_installer_custom_hiera

- include_tasks: install.yml
when: foreman_installer_upgrade == False
when: not foreman_installer_upgrade

- include_tasks: upgrade.yml
when: foreman_installer_upgrade == True
when: foreman_installer_upgrade
2 changes: 1 addition & 1 deletion roles/foreman_provisioning_infrastructure/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
register: foreman_provisioning_compute_profile_cmd
ignore_errors: True

- include: compute_profiles.yml
- include_tasks: compute_profiles.yml
when: "'Error' not in foreman_provisioning_compute_profile_cmd.stderr"

# Domain
Expand Down
7 changes: 5 additions & 2 deletions roles/foreman_proxy_content/tasks/devel_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
register: foreman_get

- name: 'Check for rails server'
fail: msg="No rails server detected running on {{ foreman_proxy_content_server }}"
fail:
msg: "No rails server detected running on {{ foreman_proxy_content_server }}"
when: foreman_get.status != 200

- name: 'Add group foreman'
group: name=foreman state=present
group:
name: foreman
state: present
delegate_to: "{{ foreman_proxy_content_server }}"
4 changes: 3 additions & 1 deletion roles/foreman_proxy_content/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
- include_tasks: certs_generate.yml

- name: 'Change cert permissions'
file: path='/etc/pki/katello/private' mode=0775
file:
path: '/etc/pki/katello/private'
mode: 0775
delegate_to: "{{ foreman_proxy_content_server }}"
when: devel is defined and devel

Expand Down
9 changes: 6 additions & 3 deletions roles/foreman_proxy_content/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
---
- include_tasks: devel_install.yml
when: (foreman_proxy_content_upgrade == False and devel is defined and devel == True)
when:
- not foreman_proxy_content_upgrade
- devel is defined
- devel

- include_tasks: install.yml
when: foreman_proxy_content_upgrade == False
when: not foreman_proxy_content_upgrade

- include_tasks: upgrade.yml
when: foreman_proxy_content_upgrade == True
when: foreman_proxy_content_upgrade
2 changes: 1 addition & 1 deletion roles/forklift_versions/tasks/versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
become: no

- name: set individual component vars
set_fact: "{{ item.key }}={{ item.value }}"
set_fact: "{{ item.key }}={{ item.value }}" # noqa: no-free-form
with_items: "{{ forklift_versions.versions | dict2items }}"
4 changes: 3 additions & 1 deletion roles/git/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
- name: 'Install git'
become: true
yum: name=git-core state=present
yum:
name: git-core
state: present
16 changes: 12 additions & 4 deletions roles/hammer_devel/tasks/hammer_config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
---
- name: 'Add hammer config directory'
file: path=~/.hammer state=directory
file:
path: '~/.hammer'
state: directory

- name: 'Add hammer module config directory'
file: path=~/.hammer/cli.modules.d state=directory
file:
path: '~/.hammer/cli.modules.d'
state: directory

- name: 'Configure hammer'
command: cp ~/hammer-cli/config/cli_config.template.yml ~/.hammer/cli_config.yml
Expand Down Expand Up @@ -76,7 +80,11 @@
when: ('theforeman/hammer-cli-foreman-virt-who-configure' in hammer_devel_repositories)

- name: 'Alias hammer'
lineinfile: dest=~/.bash_profile line="alias hammer='BUNDLE_GEMFILE=~/hammer-cli-foreman/Gemfile bundle exec hammer'"
lineinfile:
dest: '~/.bash_profile'
line: "alias hammer='BUNDLE_GEMFILE=~/hammer-cli-foreman/Gemfile bundle exec hammer'"

- name: 'Alias rake'
lineinfile: dest=~/.bash_profile line="alias rake='bundle exec rake'"
lineinfile:
dest: '~/.bash_profile'
line: "alias rake='bundle exec rake'"
8 changes: 6 additions & 2 deletions roles/hammer_devel/tasks/hammer_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@
- name: 'Install gem native dependencies'
become: true
yum: name=gcc-c++ state=present
yum:
name: gcc-c++
state: present

- name: 'Install gems'
bundler: chdir=~/hammer-cli-foreman state=present
bundler:
chdir: '~/hammer-cli-foreman'
state: present
4 changes: 2 additions & 2 deletions roles/katello_provisioning/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@
katello_provisioning_centos7: "{{ katello_provisioning_centos7_json.stdout|from_json }}"
when: katello_provisioning_centos7_json is success

- block:
- when: "'not found' in katello_provisioning_centos7_json.stderr"
block:
- name: 'Create CentOS_Linux 7'
shell: >
{{ katello_provisioning_hammer }} os create
Expand All @@ -219,7 +220,6 @@
- name: 'get new CentOS 7 info'
set_fact:
katello_provisioning_centos7: "{{ katello_provisioning_centos7_json_new.stdout|from_json }}"
when: "'not found' in katello_provisioning_centos7_json.stderr"

- name: 'update partition table for CentOS 7'
shell: >
Expand Down
3 changes: 3 additions & 0 deletions roles/katello_test/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
executable: /bin/bash
chdir: "{{ katello_test_foreman_development_dir }}"
become_user: "{{ katello_test_user }}"
become: true

- name: 'Prepare katello test database'
ansible.builtin.shell: |
Expand All @@ -29,6 +30,7 @@
executable: /bin/bash
chdir: "{{ katello_test_foreman_development_dir }}"
become_user: "{{ katello_test_user }}"
become: true

- name: 'Run katello tests'
ansible.builtin.shell: |
Expand All @@ -37,3 +39,4 @@
executable: /bin/bash
chdir: "{{ katello_test_foreman_development_dir }}"
become_user: "{{ katello_test_user }}"
become: true
4 changes: 3 additions & 1 deletion roles/libvirt/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
when: libvirt_nested

- name: 'restart libvirt'
service: name=libvirtd state=restarted
service:
name: libvirtd
state: restarted

- include_tasks: 'tftp.yml'
when: libvirt_tftp
34 changes: 27 additions & 7 deletions roles/libvirt/tasks/tftp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
# libvirt seems to have bug that it does not create the symlink even if the network was defined with auto provisioning
# so we ensure the symlink exists and network autostarts after reboot
- name: 'make provisioning network autostart on reboot'
file: state=link src=/etc/libvirt/qemu/networks/provision.xml path=/etc/libvirt/qemu/networks/autostart/provision.xml
file:
state: link
src: /etc/libvirt/qemu/networks/provision.xml
path: /etc/libvirt/qemu/networks/autostart/provision.xml

- name: 'create the provisioning storage'
virt_pool:
Expand All @@ -18,16 +21,27 @@

# Setup TFTP for libvirt
- name: 'create /var/lib/tftpboot'
file: path=/var/lib/tftpboot state=directory mode=0755
file:
path: /var/lib/tftpboot
state: directory
mode: '0755'

- name: 'create /var/lib/tftpboot/boot'
file: path=/var/lib/tftpboot/boot state=directory mode=0755
file:
path: /var/lib/tftpboot/boot
state: directory
mode: '0755'

- name: 'create /var/lib/tftpboot/pxelinux.cfg'
file: path=/var/lib/tftpboot/pxelinux.cfg state=directory mode=0755
file:
path: /var/lib/tftpboot/pxelinux.cfg
state: directory
mode: '0755'

- name: 'install syslinux for tftp directory'
yum: name=syslinux state=present
yum:
name: syslinux
state: present

- name: 'copy syslinux files to /var/lib/tftpboot'
shell: cp /usr/share/syslinux/{pxelinux.0,menu.c32,chain.c32} /var/lib/tftpboot
Expand All @@ -44,7 +58,13 @@
shell: set -o pipefail && find /var/lib/tftpboot/ -type d | xargs chmod g+s

- name: 'start the provision libvirt network'
virt_net: state=active name=provision autostart=yes
virt_net:
state: active
name: provision
autostart: yes

- name: 'start the provision libvirt storage pool'
virt_pool: state=active name=provision autostart=yes
virt_pool:
state: active
name: provision
autostart: yes
5 changes: 5 additions & 0 deletions roles/powerdns/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: "Restart PowerDNS"
service:
name: "pdns"
state: "restarted"
10 changes: 4 additions & 6 deletions roles/powerdns/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,17 @@
owner: "root"
group: "root"
mode: "{{ powerdns_conf_mode }}"
register: "pdns_configured"
notify:
- "Restart PowerDNS"

- name: "Enable PowerDNS"
service:
name: "pdns"
state: "started"
enabled: yes

- name: "Restart PowerDNS"
service:
name: "pdns"
state: "restarted"
when: pdns_configured.changed
- name: Flush handlers
meta: flush_handlers

- include_tasks: "schema.mysql.yml"
when: powerdns_db_backend == "gmysql"
Expand Down
4 changes: 3 additions & 1 deletion roles/ruby_libvirt_gem/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---
- name: 'Restart smart proxy'
service: name=foreman-proxy state=restarted
service:
name: foreman-proxy
state: restarted
4 changes: 3 additions & 1 deletion roles/ruby_libvirt_gem/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
- name: 'Install libvirt gem'
yum: name=rubygem-ruby-libvirt state=present
yum:
name: rubygem-ruby-libvirt
state: present
notify:
- 'Restart smart proxy'
2 changes: 1 addition & 1 deletion roles/umask/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
- name: "Configure system wide umask on {{ ansible_os_family }} to {{ umask_mode }}"
include_tasks: "{{ ansible_os_family|lower }}.yml"
when: umask_mode != false
when: umask_mode
11 changes: 5 additions & 6 deletions roles/unprivileged_user/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
register: authorized_keys_file
become: true

- block:
- when:
- not authorized_keys_file.stat.exists
- unprivileged_user_import_ssh_pub_key | default(True)
become: true
block:
- name: "Check /root/.ssh/authorized_keys"
stat:
path: /root/.ssh/authorized_keys
Expand All @@ -55,8 +59,3 @@
mode: 0600
dest: "/home/{{ unprivileged_user_username }}/.ssh/authorized_keys"
when: root_authorized_keys_file.stat.exists

when:
- not authorized_keys_file.stat.exists
- unprivileged_user_import_ssh_pub_key | default(True)
become: true

0 comments on commit a35fee7

Please sign in to comment.