Browse Source

initial commit

drymer 2 years ago
commit
742f0a6a49

+ 2
- 0
.gitignore View File

@@ -0,0 +1,2 @@
1
+*.pyc
2
+*cache*

+ 4
- 0
.yamllint View File

@@ -0,0 +1,4 @@
1
+extends: relaxed
2
+truthy: disable
3
+rules: {line-length: {max: 130}}
4
+

+ 44
- 0
README.md View File

@@ -0,0 +1,44 @@
1
+Qutebrowser
2
+=========
3
+
4
+Install the Qutebrowser web browser.
5
+
6
+Requirements
7
+------------
8
+
9
+None
10
+
11
+Role Variables
12
+--------------
13
+
14
+None
15
+
16
+Dependencies
17
+------------
18
+
19
+None
20
+
21
+Example Playbook
22
+----------------
23
+
24
+```yaml
25
+- hosts: servers
26
+  roles:
27
+    - { role: qutebrowser }
28
+```
29
+
30
+Compatible
31
+----------
32
+
33
+With:
34
+  - Debian 9
35
+
36
+License
37
+-------
38
+
39
+GPL3
40
+
41
+Author Information
42
+------------------
43
+
44
+drymer [ AT ] autistici.org

+ 7
- 0
molecule/default/.molecule/Dockerfile_geerlingguy_docker_debian9_ansible View File

@@ -0,0 +1,7 @@
1
+FROM geerlingguy/docker-debian9-ansible
2
+
3
+RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
4
+    elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python python-devel python2-dnf bash && dnf clean all; \
5
+    elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
6
+    elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
7
+    elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; fi

+ 10
- 0
molecule/default/.molecule/ansible.cfg View File

@@ -0,0 +1,10 @@
1
+# Molecule managed
2
+
3
+[ssh_connection]
4
+control_path = %(directory)s/%%h-%%p-%%r
5
+scp_if_ssh = True
6
+[defaults]
7
+host_key_checking = False
8
+ansible_managed = Ansible managed: Do NOT edit this file manually!
9
+retry_files_enabled = False
10
+nocows = 1

+ 11
- 0
molecule/default/.molecule/ansible_inventory.yml View File

@@ -0,0 +1,11 @@
1
+# Molecule managed
2
+
3
+---
4
+all:
5
+  hosts:
6
+    geerlingguy_docker_debian9_ansible: &id001
7
+      ansible_connection: docker
8
+ungrouped:
9
+  hosts:
10
+    geerlingguy_docker_debian9_ansible: *id001
11
+  vars: {}

+ 6
- 0
molecule/default/.molecule/state.yml View File

@@ -0,0 +1,6 @@
1
+# Molecule managed
2
+
3
+---
4
+converged: false
5
+created: false
6
+driver: null

+ 7
- 0
molecule/default/Dockerfile.j2 View File

@@ -0,0 +1,7 @@
1
+FROM {{ item.image }}
2
+
3
+RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
4
+    elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python python-devel python2-dnf bash && dnf clean all; \
5
+    elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
6
+    elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
7
+    elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; fi

+ 46
- 0
molecule/default/INSTALL.rst View File

@@ -0,0 +1,46 @@
1
+*******
2
+Install
3
+*******
4
+
5
+This set of playbooks have specific dependencies on Ansible due to the modules
6
+being used.
7
+
8
+Requirements
9
+============
10
+
11
+* Ansible 2.2
12
+* Docker Engine
13
+* docker-py
14
+
15
+Install OS dependencies on CentOS 7
16
+
17
+.. code-block:: bash
18
+
19
+  $ sudo yum install -y epel-release
20
+  $ sudo yum install -y gcc python-pip python-devel openssl-devel
21
+  # If installing Molecule from source.
22
+  $ sudo yum install libffi-devel git
23
+
24
+Install OS dependencies on Ubuntu 16.x
25
+
26
+.. code-block:: bash
27
+
28
+  $ sudo apt-get update
29
+  $ sudo apt-get install -y python-pip libssl-dev docker-engine
30
+  # If installing Molecule from source.
31
+  $ sudo apt-get install -y libffi-dev git
32
+
33
+Install OS dependencies on Mac OS
34
+
35
+.. code-block:: bash
36
+
37
+  $ brew install python
38
+  $ brew install git
39
+
40
+Install using pip:
41
+
42
+.. code-block:: bash
43
+
44
+  $ sudo pip install ansible
45
+  $ sudo pip install docker-py
46
+  $ sudo pip install molecule --pre

+ 47
- 0
molecule/default/create.yml View File

@@ -0,0 +1,47 @@
1
+---
2
+- name: Create
3
+  hosts: localhost
4
+  connection: local
5
+  gather_facts: False
6
+  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
7
+  vars:
8
+    molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
9
+    molecule_ephemeral_directory: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}"
10
+    molecule_scenario_directory: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}"
11
+    molecule_yml: "{{ lookup('file', molecule_file) | from_yaml }}"
12
+  tasks:
13
+    - name: Create Dockerfiles from image names
14
+      template:
15
+        src: "{{ molecule_scenario_directory }}/Dockerfile.j2"
16
+        dest: "{{ molecule_ephemeral_directory }}/Dockerfile_{{ item.image | regex_replace('[^a-zA-Z0-9_]', '_') }}"
17
+      with_items: "{{ molecule_yml.platforms }}"
18
+      register: platforms
19
+
20
+    - name: Discover local Docker images
21
+      docker_image_facts:
22
+        name: "molecule_local/{{ item.item.name }}"
23
+      with_items: "{{ platforms.results }}"
24
+      register: docker_images
25
+
26
+    - name: Build an Ansible compatible image
27
+      docker_image:
28
+        path: "{{ molecule_ephemeral_directory }}"
29
+        name: "molecule_local/{{ item.item.image }}"
30
+        dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}"
31
+        force: "{{ item.item.force | default(True) }}"
32
+      with_items: "{{ platforms.results }}"
33
+      when: platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0
34
+
35
+    - name: Create molecule instance(s)
36
+      docker_container:
37
+        name: "{{ item.name }}"
38
+        hostname: "{{ item.name }}"
39
+        image: "molecule_local/{{ item.image }}"
40
+        state: started
41
+        recreate: False
42
+        log_driver: syslog
43
+        command: "{{ item.command | default('sleep infinity') }}"
44
+        privileged: "{{ item.privileged | default(omit) }}"
45
+        volumes: "{{ item.volumes | default(omit) }}"
46
+        capabilities: "{{ item.capabilities | default(omit) }}"
47
+      with_items: "{{ molecule_yml.platforms }}"

+ 16
- 0
molecule/default/destroy.yml View File

@@ -0,0 +1,16 @@
1
+---
2
+- name: Destroy
3
+  hosts: localhost
4
+  connection: local
5
+  gather_facts: False
6
+  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
7
+  vars:
8
+    molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
9
+    molecule_yml: "{{ lookup('file', molecule_file) | from_yaml }}"
10
+  tasks:
11
+    - name: Destroy molecule instance(s)
12
+      docker_container:
13
+        name: "{{ item.name }}"
14
+        state: absent
15
+        force_kill: "{{ item.force_kill | default(True) }}"
16
+      with_items: "{{ molecule_yml.platforms }}"

+ 51
- 0
molecule/default/molecule.yml View File

@@ -0,0 +1,51 @@
1
+---
2
+dependency:
3
+  name: galaxy
4
+driver:
5
+  name: docker
6
+lint:
7
+  name: yamllint
8
+platforms:
9
+  - name: geerlingguy_docker_debian9_ansible
10
+    image: geerlingguy/docker-debian9-ansible
11
+    privileged: True
12
+    volumes:
13
+      - /sys/fs/cgroup:/sys/fs/cgroup:ro
14
+    command: /lib/systemd/systemd
15
+
16
+  # - name: dramaturg_debian_systemd
17
+  #   image: dramaturg/debian-systemd
18
+  #   privileged: True
19
+  #   volumes:
20
+  #     - /sys/fs/cgroup:/sys/fs/cgroup:ro
21
+  #   command: sleep infinity
22
+
23
+  # - name: centos_systemd
24
+  #   image: centos/systemd
25
+  #   privileged: True
26
+  #   volumes:
27
+  #     - /sys/fs/cgroup:/sys/fs/cgroup:ro
28
+  #   command: sleep infinity
29
+
30
+  # - name: solita_ubuntu_systemd
31
+  #   image: solita/ubuntu-systemd
32
+  #   privileged: True
33
+  #   volumes:
34
+  #     - /sys/fs/cgroup:/sys/fs/cgroup:ro
35
+  #   command: sleep infinity
36
+
37
+  # - name: ubuntu_14_04
38
+  #   image: ubuntu:14.04
39
+
40
+provisioner:
41
+  name: ansible
42
+  lint:
43
+    name: ansible-lint
44
+  options:
45
+    extra-vars: force_docker=yes
46
+scenario:
47
+  name: default
48
+verifier:
49
+  name: testinfra
50
+  lint:
51
+    name: flake8

+ 5
- 0
molecule/default/playbook.yml View File

@@ -0,0 +1,5 @@
1
+---
2
+- name: Converge
3
+  hosts: all
4
+  roles:
5
+    - role: qutebrowser

+ 15
- 0
molecule/default/tests/test_default.py View File

@@ -0,0 +1,15 @@
1
+import os
2
+
3
+import testinfra.utils.ansible_runner
4
+
5
+testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
6
+    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
7
+
8
+
9
+def test_hosts_file(host):
10
+    f = host.file('/usr/local/bin/qutebrowser')
11
+
12
+    assert f.exists
13
+    assert f.user == 'root'
14
+    assert f.group == 'staff'
15
+    assert oct(f.mode) == '0755'

+ 36
- 0
tasks/main.yml View File

@@ -0,0 +1,36 @@
1
+---
2
+# tasks file for qutebrowser
3
+- name: Install dependencies
4
+  become: yes
5
+  apt:
6
+    name: "{{ item }}"
7
+    state: present
8
+  with_items:
9
+    - python3-pip
10
+    - python3-lxml
11
+    - python-tox
12
+    - python3-pyqt5
13
+    - python3-pyqt5.qtwebkit
14
+    - python3-pyqt5.qtquick
15
+    - python3-sip
16
+    - python3-jinja2
17
+    - python3-pygments
18
+    - python3-yaml
19
+    - python3-pyqt5.qtsql
20
+    - libqt5sql5-sqlite
21
+    - python3-pyqt5.qtwebengine
22
+    - python3-pyqt5.qtopengl
23
+
24
+- name: Install PyOpenGL
25
+  become: yes
26
+  pip:
27
+    name: PyOpenGL
28
+    executable: pip3
29
+    state: present
30
+
31
+- name: Install qutebrowser
32
+  become: yes
33
+  pip:
34
+    name: qutebrowser
35
+    executable: pip3
36
+    state: present

Loading…
Cancel
Save