Skip to content

Commit

Permalink
Merge pull request #532 from ripleymj/ansible-lint-vars
Browse files Browse the repository at this point in the history
Ansible lint vars
  • Loading branch information
ripleymj authored Oct 4, 2023
2 parents b1c7568 + 070a096 commit 253eafe
Show file tree
Hide file tree
Showing 22 changed files with 68 additions and 66 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
- name: Install dependencies
run: |
pip3 install ansible ansible-lint yamllint
- name: Create log directory
run: |
sudo mkdir /var/log/vmtools/
sudo chmod 777 /var/log/vmtools/
- name: Run ansible-lint
run: |
ansible-lint -R -r lintrules/ansible
Expand Down
12 changes: 6 additions & 6 deletions roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
DEBIAN_FRONTEND: noninteractive
- name: Ensure log directory exists
ansible.builtin.file:
path: "{{ log_directory }}"
path: "{{ common_log_directory }}"
state: directory
mode: "0755"
- name: Create directory for shared data
ansible.builtin.file:
path: "{{ share_directory }}"
path: "{{ common_share_directory }}"
state: directory
owner: root
group: root
Expand All @@ -37,24 +37,24 @@
- name: Install Ansible wrapper GUI script
ansible.builtin.template:
src: uug_ansible_wrapper.py
dest: '{{ uug_ansible_wrapper }}'
dest: '{{ common_uug_ansible_wrapper }}'
mode: "0755"
- name: Install JMU-colored Tux icon
ansible.builtin.copy:
src: jmu-tux.svg
dest: "/usr/share/icons/hicolor/scalable/apps/{{ tux_icon_name }}.svg"
dest: "/usr/share/icons/hicolor/scalable/apps/{{ common_tux_icon_name }}.svg"
mode: "0644"
notify: Update icon cache

- name: Ensure local applications folder exists
ansible.builtin.file:
path: "{{ wrapper_desktop_file_path }}"
path: "{{ common_wrapper_desktop_file_path }}"
state: directory
mode: "0755"
- name: Copy shortcut to desktop file directory
ansible.builtin.template:
src: desktop-template.desktop.j2
dest: "{{ wrapper_desktop_file_path }}/jmucs_config.desktop"
dest: "{{ common_wrapper_desktop_file_path }}/jmucs_config.desktop"
mode: "0755"

- name: Load Ubuntu tasks
Expand Down
12 changes: 6 additions & 6 deletions roles/common/templates/CustomMintReportInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

# NOTE: This file is parsed by Jinja2 as part of an Ansible playbook.
# The following values were interpreted:
# tux_icon_name: {{ tux_icon_name }}
# global_profile_path: {{ global_profile_path }}
# uug_ansible_wrapper: {{ uug_ansible_wrapper }}
# common_tux_icon_name: {{ common_tux_icon_name }}
# common_global_profile_path: {{ common_global_profile_path }}
# common_uug_ansible_wrapper: {{ common_uug_ansible_wrapper }}

"""
Custom mintreport script for ensuring the JMU CS VM Config Tool has been run on
Expand Down Expand Up @@ -38,15 +38,15 @@ class Report(InfoReport):
def __init__(self):

self.title = "Run JMU CS Config Tool"
self.icon = "{{ tux_icon_name }}"
self.icon = "{{ common_tux_icon_name }}"
self.has_ignore_button = False

def is_pertinent(self):
"""
Validates whether this report should be shown the mintreport
"""

return not os.path.exists('{{ global_profile_path }}')
return not os.path.exists('{{ common_global_profile_path }}')

def get_descriptions(self):
"""
Expand Down Expand Up @@ -84,7 +84,7 @@ def callback(self, data):
"""

subprocess.run(
["{{ uug_ansible_wrapper }}"],
["{{ common_uug_ansible_wrapper }}"],
start_new_session=True, check=False
)
return True
Expand Down
4 changes: 2 additions & 2 deletions roles/common/templates/desktop-template.desktop.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Type=Application
Version=1.0
Name=JMU CS VM Configuration
Comment=Update and configure courses
Exec={{ uug_ansible_wrapper }}
Icon={{ tux_icon_name }}
Exec={{ common_uug_ansible_wrapper }}
Icon={{ common_tux_icon_name }}
Categories=System;
StartupWMClass=uug_ansible_wrapper.py
4 changes: 2 additions & 2 deletions roles/common/templates/mint.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Place modifications in another file in /etc/apt/sources.list.d/ with a .list
# file extension.

{% for mirror in ubuntu_mirrors %}
{% for mirror in common_ubuntu_mirrors %}
# Upstream Ubuntu sources for {{ mirror }}
deb {{ mirror }} {{ ubuntu_release }} main restricted universe multiverse
deb {{ mirror }} {{ ubuntu_release }}-updates main restricted universe multiverse
Expand All @@ -13,7 +13,7 @@ deb {{ mirror }} {{ ubuntu_release }}-security main restricted universe multiver

{% endfor %}

{% for mirror in mint_mirrors %}
{% for mirror in common_mint_mirrors %}
# Mint sources for {{ mirror }}
deb {{ mirror }} {{ ansible_distribution_release }} main upstream import backport

Expand Down
2 changes: 1 addition & 1 deletion roles/common/templates/ubuntu.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Place modifications in another file in /etc/apt/sources.list.d/ with a .list
# file extension.

{% for mirror in ubuntu_mirrors %}
{% for mirror in common_ubuntu_mirrors %}
deb {{ mirror }} {{ ubuntu_release }} main restricted universe multiverse
deb {{ mirror }} {{ ubuntu_release }}-updates main restricted universe multiverse
deb {{ mirror }} {{ ubuntu_release }}-backports main restricted universe multiverse
Expand Down
6 changes: 3 additions & 3 deletions roles/common/templates/uug_ansible_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(self):

# Attempt to use tux as the icon. If it fails, that's okay
try:
self.set_icon_name("{{ tux_icon_name }}")
self.set_icon_name("{{ common_tux_icon_name }}")
except GLib.GError as err:
logging.warning("Unable to set Tux icon", exc_info=err)

Expand Down Expand Up @@ -297,7 +297,7 @@ def show_about_dialog(self, _):
"""

about_dialog = Gtk.AboutDialog()
about_dialog.set_logo_icon_name("{{ tux_icon_name }}")
about_dialog.set_logo_icon_name("{{ common_tux_icon_name }}")
about_dialog.set_transient_for(self)
about_dialog.set_program_name(NAME)
about_dialog.set_copyright("Copyright \xa9 2018-2022 JMU Unix Users Group")
Expand Down Expand Up @@ -376,7 +376,7 @@ def sub_command_exited(self, _, exit_status):
"There was an error while running the configuration tasks. "
"Please try again."
"\nIf this issue continues to occur, copy"
" {{ ansible_log_file }} and"
" {{ common_ansible_log_file }} and"
f" <a href='{USER_CONFIG['git_url']}'>create an issue</a>"
)
show_dialog(
Expand Down
20 changes: 10 additions & 10 deletions roles/common/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---
# vars file for common
ubuntu_mirrors:
common_ubuntu_mirrors:
- "https://mirror.cs.jmu.edu/pub/ubuntu"
- "http://us.archive.ubuntu.com/ubuntu"

mint_mirrors:
common_mint_mirrors:
- "https://mirror.cs.jmu.edu/pub/linuxmint/packages"
- "http://packages.linuxmint.com"

global_base_path: "/opt"
global_profile_path: "{{ global_base_path }}/csvmprofile"
common_global_base_path: "/opt"
common_global_profile_path: "{{ common_global_base_path }}/csvmprofile"

log_directory: "/var/log/vmtools"
ansible_log_file: "{{ log_directory }}/ansible_runs.log"
common_log_directory: "/var/log/vmtools"
common_ansible_log_file: "{{ common_log_directory }}/ansible_runs.log"

share_directory: "/usr/local/share/jmu-uug"
uug_ansible_wrapper: "{{ share_directory }}/uug_ansible_wrapper.py"
common_share_directory: "/usr/local/share/jmu-uug"
common_uug_ansible_wrapper: "{{ common_share_directory }}/uug_ansible_wrapper.py"

tux_icon_name: "edu.jmu.uug.tux"
common_tux_icon_name: "edu.jmu.uug.tux"

wrapper_desktop_file_path: "/usr/local/share/applications"
common_wrapper_desktop_file_path: "/usr/local/share/applications"
2 changes: 1 addition & 1 deletion roles/eclipse/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
state: absent
- name: Unpack Eclipse bundle
ansible.builtin.unarchive:
dest: '{{ global_base_path }}'
dest: '{{ common_global_base_path }}'
src: '{{ eclipse.zip }}'
owner: root
group: root
Expand Down
6 changes: 3 additions & 3 deletions roles/eclipse/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
# vars file for eclipse
eclipse:
eclipse: # noqa var-naming[no-role-prefix]
# Ensure the URL does not specify a mirror and that &r=1 is at the end, which
# directly links to the file and not the web page with a download button
url: 'https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2023-06/R/eclipse-java-2023-06-R-linux-gtk-{{ ansible_architecture }}.tar.gz&r=1'
url_backup: 'https://download.eclipse.org/technology/epp/downloads/release/2023-06/R/eclipse-java-2023-06-R-linux-gtk-{{ ansible_architecture }}.tar.gz'
hash:
x86_64: '8a54f3fb7abb3203559b4db403681a815edc406a'
aarch64: '958626a64c455c5e1a9e14c44526748ba2ce81d9'
zip: '{{ global_base_path }}/eclipse.tar.gz'
install_path: '{{ global_base_path }}/eclipse'
zip: '{{ common_global_base_path }}/eclipse.tar.gz'
install_path: '{{ common_global_base_path }}/eclipse'

eclipse_remove_mint:
- eclipse-jdt
Expand Down
14 changes: 7 additions & 7 deletions roles/oem/tasks/mint_only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

- name: Update mintupdate package
ansible.builtin.apt:
name: "{{ upgrade_pre_mintupdate }}"
name: "{{ oem_upgrade_pre_mintupdate }}"
state: latest
- name: Upgrade all installed packages # noqa no-changed-when
ansible.builtin.command:
Expand All @@ -17,29 +17,29 @@

- name: Ensure skeleton desktop directory exists
ansible.builtin.file:
path: "{{ skel_desktop_file_path }}"
path: "{{ oem_skel_desktop_file_path }}"
state: directory
mode: "0755"
- name: Copy welcome shortcut to skeleton desktop directory
ansible.builtin.copy:
src: welcome-to-vm.desktop
dest: "{{ skel_desktop_file_path }}/welcome-to-vm.desktop"
dest: "{{ oem_skel_desktop_file_path }}/welcome-to-vm.desktop"
mode: "0644"
- name: Hide the mintwelcome window
ansible.builtin.file:
path: "{{ skel_path }}/.linuxmint/mintwelcome"
path: "{{ oem_skel_path }}/.linuxmint/mintwelcome"
mode: "0755"
state: directory
- name: Hide the mintwelcome window
ansible.builtin.copy:
dest: "{{ skel_path }}/.linuxmint/mintwelcome/norun.flag"
dest: "{{ oem_skel_path }}/.linuxmint/mintwelcome/norun.flag"
mode: "0664"
content: ""
force: no
- name: Copy setup script shortcut to desktop
ansible.builtin.copy:
src: "{{ wrapper_desktop_file_path }}/jmucs_config.desktop"
dest: "{{ skel_desktop_file_path }}/jmucs_config.desktop"
src: "{{ common_wrapper_desktop_file_path }}/jmucs_config.desktop"
dest: "{{ oem_skel_desktop_file_path }}/jmucs_config.desktop"
mode: "0755"
- name: Copy dconf config file
ansible.builtin.copy:
Expand Down
4 changes: 2 additions & 2 deletions roles/oem/tasks/ubuntu_only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
- Update dconf database
- name: Create skeleton config dir
ansible.builtin.file:
path: "{{ skel_path }}/.config/"
path: "{{ oem_skel_path }}/.config/"
mode: "0755"
state: directory
- name: Hide the GNOME welcome
ansible.builtin.copy:
dest: "{{ skel_path }}/.config/gnome-initial-setup-done"
dest: "{{ oem_skel_path }}/.config/gnome-initial-setup-done"
mode: "0664"
content: ""
force: no
2 changes: 1 addition & 1 deletion roles/oem/tasks/vm_only_pre.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Tasks for the oem role to run at the beginning of playbook execution
- name: Remove unneeded stock packages
ansible.builtin.apt:
name: '{{ packages_to_remove }}'
name: '{{ oem_packages_to_remove }}'
state: absent
purge: yes
- name: Remove i386 architecture
Expand Down
8 changes: 4 additions & 4 deletions roles/oem/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
# vars file for oem
upgrade_pre_mintupdate:
oem_upgrade_pre_mintupdate:
- mintupdate
- mint-upgrade-info

skel_path: "/etc/skel"
skel_desktop_file_path: "{{ skel_path }}/Desktop"
oem_skel_path: "/etc/skel"
oem_skel_desktop_file_path: "{{ oem_skel_path }}/Desktop"

# https://github.com/jmunixusers/cs-vm-build/issues/11#issuecomment-347015788
packages_to_remove:
oem_packages_to_remove:
- bluez*
- btrfs-tools
- fonts*gujr*
Expand Down
6 changes: 3 additions & 3 deletions roles/programming_langs/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

- name: Install Ruby packages
ansible.builtin.apt:
name: "{{ ruby_packages }}"
name: "{{ programming_langs_ruby_packages }}"
state: latest

- name: Install Haskell packages
ansible.builtin.apt:
name: "{{ haskell_packages }}"
name: "{{ programming_langs_haskell_packages }}"
state: latest

- name: Install Prolog packages
ansible.builtin.apt:
name: "{{ prolog_packages }}"
name: "{{ programming_langs_prolog_packages }}"
state: latest
6 changes: 3 additions & 3 deletions roles/programming_langs/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
# vars file for programming-langs
ruby_packages:
programming_langs_ruby_packages:
- ruby

haskell_packages:
programming_langs_haskell_packages:
- haskell-platform

prolog_packages:
programming_langs_prolog_packages:
- swi-prolog
8 changes: 4 additions & 4 deletions roles/user/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# tasks file for user
- name: Create opt directory
ansible.builtin.file:
path: "{{ global_base_path }}"
path: "{{ common_global_base_path }}"
state: directory
owner: root
group: root
Expand Down Expand Up @@ -49,7 +49,7 @@
- name: Touch VM profile
ansible.builtin.copy:
src: csvmprofile
dest: '{{ global_profile_path }}'
dest: '{{ common_global_profile_path }}'
mode: "0644"
owner: root
group: root
Expand All @@ -68,7 +68,7 @@
# Per ssh_config(5), this is the default value of GlobalKnownHostsFile
path: /etc/ssh/ssh_known_hosts
name: stu.cs.jmu.edu
key: "{{ stu_host_key }}"
key: "{{ user_stu_host_key }}"
hash_host: yes
state: present
- name: Create stu-home bookmark
Expand All @@ -85,7 +85,7 @@
- name: Add profile to user bashrc
ansible.builtin.lineinfile:
path: '{{ item.homedir }}/.bashrc'
line: "source {{ global_profile_path }}"
line: "source {{ common_global_profile_path }}"
state: present
insertafter: EOF
# We don't want to break things by having a very basic .bashrc that just
Expand Down
4 changes: 1 addition & 3 deletions roles/user/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---
# vars file for user
global_profile_path: "{{ global_base_path }}/csvmprofile"

user_dependencies:
- default-jdk
- libnotify-bin
Expand All @@ -10,4 +8,4 @@ user_dependencies:
- vim
- vim-gtk3

stu_host_key: "stu.cs.jmu.edu ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILXS19kf1swKRC9GTTiUDyOzra0sYT+kt6Vxd4Q0H9uw"
user_stu_host_key: "stu.cs.jmu.edu ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILXS19kf1swKRC9GTTiUDyOzra0sYT+kt6Vxd4Q0H9uw"
2 changes: 1 addition & 1 deletion roles/wireless_printing/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
-o "printer-is-shared=false"
register: lpstat_result
changed_when: '"Invalid destination name" in lpstat_result.stderr'
with_items: "{{ printers }}"
with_items: "{{ wireless_printing_printers }}"
Loading

0 comments on commit 253eafe

Please sign in to comment.