Skip to content

Commit

Permalink
some work on printer drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinth committed Jul 11, 2024
1 parent a04d6c8 commit b1b69e8
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 5 deletions.
5 changes: 4 additions & 1 deletion roles/install_homebrew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
get_url:
url: "https://github.com/Homebrew/brew/releases/download/{{ homebrew_json.json.tag_name }}/Homebrew-{{ homebrew_json.json.tag_name }}.pkg"
dest: /tmp/homebrew-latest.pkg
force: true
register: downloaded
- name: Install downloaded pkg | cmd
become: true
ansible.builtin.command:
cmd: installer -pkg /tmp/homebrew-latest.pkg -target /
become: true
when: downloaded.status_code == 200
- name: Configure repository origin | cmd
ansible.builtin.command:
cmd: 'git -C "/opt/homebrew" remote add origin https://github.com/Homebrew/brew'
Expand Down
11 changes: 9 additions & 2 deletions roles/install_printer.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
- name: Install printers
hosts: workstations
# hosts: workstations
hosts: michal-macbook-pro-m1
vars:
# taking the link from european version of Canon website and resolving the redirect via wget
# temporary measure, in the future i would like to automatically download the latest version of the driver somehow
driver_lnx: "https://gdlp01.c-wss.com/gds/8/0100007658/40/linux-UFRII-drv-v590-m17n-03.tar.gz"
driver_osx: "https://gdlp01.c-wss.com/gds/8/0100012238/02/mac-UFRII-LIPSLX-v101919-06.dmg"
driver_scan_osx: "https://gdlp01.c-wss.com/gds/5/0100012265/01/mac-scan-v21515-00.dmg"
tasks:
- ansible.builtin.include_tasks:
file: ./install_printer_mac.yaml
file: ./install_printer_osx.yaml
when: ansible_distribution == "MacOSX"
- ansible.builtin.include_tasks:
file: ./install_printer_deb.yaml
Expand Down
47 changes: 47 additions & 0 deletions roles/install_printer_deb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
- name: Download the linux driver package | get_url
ansible.builtin.get_url:
url: "{{ driver_lnx }}"
dest: /tmp/mf270_driver.tar.gz
force: true
register: downloaded
- name: Create a temp directory | file
ansible.builtin.file:
path: /tmp/mf270_driver
state: directory
when: downloaded.status_code == 200
- name: Unarchive the linux package | unarchive
ansible.builtin.unarchive:
src: /tmp/mf270_driver.tar.gz
dest: /tmp/mf270_driver
extra_opts: ['--strip-components=1', '--show-stored-names']
when: downloaded.status_code == 200
- name: Find the extracted deb file name | find
ansible.builtin.find:
path: /tmp/mf270_driver/x64/Debian
patterns: '*.deb'
register: filename_search
- name: Check installed package facts | package_facts
ansible.builtin.package_facts:
manager: "apt"
- name: Set variables | set_fact
ansible.builtin.set_fact:
filename: "{{ filename_search.files[0].path | basename }}"

Check warning on line 28 in roles/install_printer_deb.yaml

View workflow job for this annotation

GitHub Actions / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{ filename_search.files[0].path | basename | regex_search('_([0-9-\.]+)_','\1') | first }} -> {{ filename_search.files[0].path | basename | regex_search('_([0-9-\.]+)_', '\1') | first }}
new_version: "{{ filename_search.files[0].path | basename | regex_search('_([0-9-\\.]+)_','\\1') | first }}"
current_version: "{{ ansible_facts.packages['cnrdrvcups-ufr2-uk'][0].version }}"
- name: Info | debug
ansible.builtin.debug:
msg: "Driver not installed. Installing version {{ new_version }}..."
when: current_version is not defined
- name: Info | debug
ansible.builtin.debug:
msg: "Current version: {{ current_version }}\nNew version: {{ new_version }}.\n Proceeding with update..."
when: current_version != new_version
- name: Info | fail
ansible.builtin.fail:
msg: "Current version is the same as new version."
when: current_version == new_version
- name: Install the package | apt
become: true
ansible.builtin.apt:
deb: "/tmp/mf270_driver/x64/Debian/{{ filename }}"
when: new_version != current_version
21 changes: 21 additions & 0 deletions roles/install_printer_osx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
- name: Download the mac driver package | get_url
ansible.builtin.get_url:
url: "{{ driver_osx }}"
dest: /tmp/mf270_driver.dmg
force: true
- name: Unarchive the mac driver package | unarchive
ansible.builtin.unarchive:
src: /tmp/mf270_driver.dmg
dest: /tmp/
remote_src: true
- name: Download the mac scanner driver package | get_url
ansible.builtin.get_url:
url: "{{ driver_scan_osx }}"
dest: /tmp/mf270_scan_driver.dmg
force: true
- name: Unarchive the mac scanner driver package | unarchive
ansible.builtin.unarchive:
src: /tmp/mf270_scan_driver.dmg
dest: /tmp/
remote_src: true

22 changes: 20 additions & 2 deletions roles/required_pkgs_apt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
become: true
ansible.builtin.apt:
state: latest
update_cache: true
update_cache: false
name: neovim
register: output
- name: Show output
Expand All @@ -20,8 +20,26 @@
become: true
ansible.builtin.apt:
state: latest
update_cache: true
update_cache: false
name: zsh
register: output
- name: Show output
debug: msg="{{ output.stdout_lines }}"
- name: Install hwinfo on Debian derivatives | apt
become: true
ansible.builtin.apt:
state: latest
update_cache: false
name: hwinfo
register: output
- name: Show output
debug: msg="{{ output.stdout_lines }}"
- name: Install inxi on Debian derivatives | apt
become: true
ansible.builtin.apt:
state: latest
update_cache: false
name: inxi
register: output
- name: Show output
debug: msg="{{ output.stdout_lines }}"

0 comments on commit b1b69e8

Please sign in to comment.