Skip to content

Commit

Permalink
Chrome (#8)
Browse files Browse the repository at this point in the history
* init

* passed molecule test

* add matrix

* asserted
  • Loading branch information
huangjien authored Nov 30, 2023
1 parent 8135ac0 commit f6899eb
Show file tree
Hide file tree
Showing 10 changed files with 189 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
- apache-ant
- jfrog
- nodejs
- chrome
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: release

# Controls when the workflow will run
on:
# Triggers the workflow on push
# Triggers the workflow on push
push:
branches: [main]

Expand All @@ -12,10 +12,9 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Deploy the collection
uses: artis3n/ansible_galaxy_collection@v2
with:
api_key: ${{ secrets.GALAXY_TOKEN }}
- uses: actions/checkout@v2

- name: Deploy the collection
uses: artis3n/ansible_galaxy_collection@v2
with:
api_key: ${{ secrets.GALAXY_TOKEN }}
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace: merative
name: spm_toolbox

# The version of the collection. Must be compatible with semantic versioning
version: 1.1.0
version: 1.1.1

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand Down
9 changes: 9 additions & 0 deletions molecule/chrome/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Converge
hosts: all

collections:
- merative.spm_toolbox

roles:
- chrome
31 changes: 31 additions & 0 deletions molecule/chrome/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
driver:
name: docker
provider:
name: docker

lint: |
set -e
yamllint .
platforms:
- name: rockylinux8
image: rockylinux:8
dockerfile: ../_resources/Dockerfile.j2
pre_build_image: False
privileged: True
volume_mounts:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
environment:
container: docker

provisioner:
name: ansible
log: true
config_options:
defaults:
stderr_callback: debug
stdout_callback: debug
env:
ANSIBLE_FORCE_COLOR: 'true'
25 changes: 25 additions & 0 deletions molecule/chrome/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# This is an example playbook to execute Ansible tests.

- name: Verify
hosts: all

pre_tasks:
- name: Check if chrome installed
stat:
path: "/usr/bin/google-chrome"
register: chrome_check

- name: Check if chromedriver installed
stat:
path: "/usr/local/chromedriver"
register: chromedriver_installed

tasks:
- name: Check that chrome exists
assert:
that: chrome_check.stat.exists

- name: Check chromedriver installed
assert:
that: chromedriver_installed.stat.exists
39 changes: 39 additions & 0 deletions roles/chrome/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# chrome

The `chrome` role downloads chrome and chromedriver appropriate for the OS.

## Requirements

None

## Role Variables

| Property Name | Default value |
| ----------------- | ------------- |
| `chrome_owner` | `root` |
| `chrome_group` | `root` |

The chrome always use `$latest` version for Linux platforms to download the latest available binary.

## Dependencies

None

## Example Playbook

```
---
- name: Install Chrome
hosts: all
collections:
- merative.spm_toolbox
roles:
- chrome
```

## License

MIT
4 changes: 4 additions & 0 deletions roles/chrome/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
chrome_owner: 'root'
chrome_group: 'root'
chromedriver_version: '114.0.5735.90' # https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_linux64.zip
39 changes: 39 additions & 0 deletions roles/chrome/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
galaxy_info:
author: SPM DevOps Team
description: Download Chrome and Chromedriver appropriate for the OS.
company: Merative

# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker

license: MIT

min_ansible_version: 2.9

#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: EL
versions:
- '7'
- '8'

galaxy_tags:
[]
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.

dependencies:
[]
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
34 changes: 34 additions & 0 deletions roles/chrome/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
- name: Install required packages (wget)
package:
name:
- wget
state: latest

- name: Download and Install Linux chromedriver
get_url:
url: "https://chromedriver.storage.googleapis.com/{{ chromedriver_version }}/chromedriver_linux64.zip"
dest: '/usr/local/chromedriver'
owner: "{{ chrome_owner }}"
group: "{{ chrome_group }}"
mode: '0755'

- name: Install Chrome
become: yes
become_user: root
shell: |
wget https://dl.google.com/linux/linux_signing_key.pub
rpm --import linux_signing_key.pub
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
dnf -y install google-chrome-stable_current_x86_64.rpm
register: script_res
changed_when: "'changed' in script_res.stdout"

- name: Remove installation files
file:
path: "{{ item }}"
state: absent
with_items:
- linux_signing_key.pub
- google-chrome-stable_current_x86_64.rpm
changed_when: false

0 comments on commit f6899eb

Please sign in to comment.