Browse Source

initial commit

drymer 2 years ago
commit
eae0dd2a21

+ 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
+

+ 45
- 0
README.md View File

@@ -0,0 +1,45 @@
1
+i3-gaps
2
+=========
3
+
4
+Install i3-gaps and i3blocks-gaps.
5
+
6
+Requirements
7
+------------
8
+
9
+None.
10
+
11
+Role Variables
12
+--------------
13
+
14
+* `install_dir`: Path in which clone the repository.
15
+* `i3_gaps_version`: i3-gaps version. [Default: 4.14.1]
16
+
17
+Dependencies
18
+------------
19
+
20
+None
21
+
22
+Example Playbook
23
+----------------
24
+
25
+```yaml
26
+- hosts: servers
27
+  roles:
28
+    - { role: i3-gaps, install_dir: ~/Instalados/ }
29
+```
30
+
31
+Compatible
32
+----------
33
+
34
+With:
35
+  - Debian 9
36
+
37
+License
38
+-------
39
+
40
+GPL3
41
+
42
+Author Information
43
+------------------
44
+
45
+drymer [ EN ] autistici.org

+ 3
- 0
defaults/main.yml View File

@@ -0,0 +1,3 @@
1
+---
2
+install_dir:
3
+i3_gaps_version: "4.14.1"

+ 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 }}"

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

@@ -0,0 +1,26 @@
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
+provisioner:
16
+  name: ansible
17
+  lint:
18
+    name: ansible-lint
19
+  options:
20
+    extra-vars: force_docker=yes
21
+scenario:
22
+  name: default
23
+verifier:
24
+  name: testinfra
25
+  lint:
26
+    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: i3-gaps, install_dir: "~/Instalados/"}

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

@@ -0,0 +1,14 @@
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('/etc/hosts')
11
+
12
+    assert f.exists
13
+    assert f.user == 'root'
14
+    assert f.group == 'root'

+ 87
- 0
tasks/main.yml View File

@@ -0,0 +1,87 @@
1
+---
2
+# tasks file for i3-gaps
3
+- name: Install dependencies
4
+  become: yes
5
+  apt:
6
+    name: "{{ item }}"
7
+    state: present
8
+  with_items:
9
+    - autoconf
10
+    - build-essential
11
+    - libxcb-keysyms1-dev
12
+    - libpango1.0-dev
13
+    - libxcb-util0-dev
14
+    - xcb
15
+    - libxcb1-dev
16
+    - libxcb-icccm4-dev
17
+    - libyajl-dev
18
+    - libev-dev
19
+    - libxcb-xkb-dev
20
+    - libxcb-cursor-dev
21
+    - libxkbcommon-dev
22
+    - libxcb-xinerama0-dev
23
+    - libxkbcommon-x11-dev
24
+    - libstartup-notification0-dev
25
+    - libxcb-randr0-dev
26
+    - libxcb-xrm0
27
+    - libxcb-xrm-dev
28
+
29
+- name: Install i3blocks-gaps
30
+  include_role:
31
+    name: i3blocks-gaps
32
+
33
+- name: Clone i3-gaps repository
34
+  git:
35
+    repo: "https://github.com/Airblader/i3"
36
+    dest: "{{ install_dir }}/i3-gaps/"
37
+    version: "{{ i3_gaps_version }}"
38
+  register: cloned
39
+
40
+- name: Reconfigure
41
+  command: autoreconf --force --install
42
+  args:
43
+    chdir: "{{ install_dir }}/i3-gaps/"
44
+  when: cloned.changed
45
+  tags:
46
+    - skip_ansible_lint
47
+
48
+- name: Delete build directory
49
+  file:
50
+    name: "{{ install_dir }}/i3-gaps/build"
51
+    state: absent
52
+  when: cloned.changed
53
+  tags:
54
+    - skip_ansible_lint
55
+
56
+- name: Create build directory
57
+  file:
58
+    name: "{{ install_dir }}/i3-gaps/build"
59
+    state: directory
60
+  when: cloned.changed
61
+  tags:
62
+    - skip_ansible_lint
63
+
64
+- name: Configure
65
+  command: ../configure --prefix=/usr --sysconfdir=/etc --disable-sanitizers
66
+  args:
67
+    chdir: "{{ install_dir }}/i3-gaps/build/"
68
+  when: cloned.changed
69
+  tags:
70
+    - skip_ansible_lint
71
+
72
+- name: Compile
73
+  command: make
74
+  args:
75
+    chdir: "{{ install_dir }}/i3-gaps/build/"
76
+  when: cloned.changed
77
+  tags:
78
+    - skip_ansible_lint
79
+
80
+- name: Install
81
+  become: yes
82
+  command: make install
83
+  args:
84
+    chdir: "{{ install_dir }}/i3-gaps/build/"
85
+  when: cloned.changed
86
+  tags:
87
+    - skip_ansible_lint

Loading…
Cancel
Save