diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index abb140ab07833bad0f157db650310048451cd91d..cc542ffd9963c7b00275a44f10a1992b6de30e6a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,18 +1,55 @@ +--- repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - sha: v1.1.1 - hooks: - - id: check-added-large-files - - id: check-yaml - - id: check-merge-conflict - - id: check-symlinks -- repo: https://www.shore.co.il/git/ansible-pre-commit - sha: v0.7.0 - hooks: - - id: ansible-syntax-check - files: &playbooks 'desktop.yml|dropbox\.yml|pkgs\.yml|skype\.yml|workstation\.yml|vscode\.yml' -- repo: https://github.com/willthames/ansible-lint - sha: v3.4.16 - hooks: - - id: ansible-lint + - repo: https://github.com/pre-commit/pre-commit-hooks.git + rev: v3.4.0 + hooks: + - id: check-added-large-files + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: check-symlinks + - id: trailing-whitespace + + - repo: https://github.com/Yelp/detect-secrets + rev: v0.14.3 + hooks: + - id: detect-secrets + + - repo: https://github.com/adrienverge/yamllint + rev: v1.25.0 + hooks: + - id: yamllint + + - repo: https://github.com/amperser/proselint/ + rev: 0.10.2 + hooks: + - id: proselint + types: [plain-text] + exclude: LICENSE + + - repo: https://github.com/executablebooks/mdformat.git + rev: 0.5.3 + hooks: + - id: mdformat + + - repo: https://git.shore.co.il/nimrod/shell-pre-commit.git + rev: v0.6.0 + hooks: + - id: shell-lint + + - repo: https://github.com/shellcheck-py/shellcheck-py.git + rev: v0.7.1.1 + hooks: + - id: shellcheck + + - repo: https://git.shore.co.il/ansible/ansible-pre-commit.git + rev: v0.10.0 + hooks: + - id: ansible-syntax-check + files: &playbooks |- + 'desktop.yml|dropbox\.yml|pkgs\.yml|skype\.yml|workstation\.yml|vscode\.yml' + + - repo: https://github.com/ansible/ansible-lint + rev: v4.3.7 + hooks: + - id: ansible-lint files: *playbooks diff --git a/desktop.yml b/desktop.yml index 9740133d02c437bc2af41fb918a70a3559f04ca0..a7a527734d4cf5aabe786654471257fb8dc91f1c 100644 --- a/desktop.yml +++ b/desktop.yml @@ -1,84 +1,90 @@ --- - hosts: all - become: yes + become: true become_user: root handlers: - - name: Update initramfs - command: /usr/sbin/update-initramfs -u + - name: Update initramfs + command: /usr/sbin/update-initramfs -u - - name: Update GRUB - command: /usr/sbin/update-grub + - name: Update GRUB + command: /usr/sbin/update-grub tasks: - - name: Assertions - assert: - that: - - ansible_pkg_mgr == 'apt' + - name: Assertions + assert: + that: + - ansible_pkg_mgr == 'apt' - - name: Add libdvdcss APT repository key - apt_key: + - name: Add libdvdcss APT repository key + apt_key: url: http://download.videolan.org/pub/debian/videolan-apt.asc state: present - - name: Add libdvdcss APT repository - with_items: + - name: Add libdvdcss APT repository + with_items: - deb - deb-src - apt_repository: + apt_repository: repo: '{{ item }} http://download.videolan.org/pub/debian/stable/ /' state: present - update_cache: yes + update_cache: true - - name: Add the Debian experimental suite repository - with_items: + - name: Add the Debian experimental suite repository + with_items: - deb - deb-src - apt_repository: + apt_repository: repo: '{{ item }} http://httpredir.debian.org/debian experimental main' state: present - update_cache: yes + update_cache: true - - name: Prioritize browsers from the Debian experimental suite - template: + - name: Prioritize browsers from the Debian experimental suite + template: src: experimental.j2 dest: /etc/apt/preferences.d/experimental owner: root group: root mode: 0o0644 - - name: APT install - with_items: - - plymouth - - initramfs-tools - - libdvdcss2 - apt: - name: '{{ item }}' - state: present - update_cache: yes - cache_valid_time: 3600 - - name: Configure Plymouth - ini_file: - dest: /etc/plymouth/plymouthd.conf - section: Daemon - option: Theme - value: spinner - register: configure_plymouth + - name: APT install + with_items: + - plymouth + - initramfs-tools + - libdvdcss2 + apt: + name: '{{ item }}' + state: present + update_cache: true + cache_valid_time: 3600 + - name: Configure Plymouth + ini_file: + dest: /etc/plymouth/plymouthd.conf + section: Daemon + option: Theme + value: spinner + register: configure_plymouth - - name: Configure GRUB - with_dict: - GRUB_TIMEOUT: 1 - GRUB_CMDLINE_LINUX_DEFAULT: 'quiet cgroup_enable=memory splash allow-discards root_trim=yes swapaccount=1' - lineinfile: - dest: /etc/default/grub - line: '{{ item.key }}="{{ item.value }}"' - regexp: '^{{ item.key }}=' - state: present - register: configure_grub + - name: Configure GRUB + with_dict: + GRUB_TIMEOUT: 1 + GRUB_CMDLINE_LINUX_DEFAULT: >- + quiet + cgroup_enable=memory + splash + allow-discards + root_trim=yes + swapaccount=1 + lineinfile: + dest: /etc/default/grub + line: '{{ item.key }}="{{ item.value }}"' + regexp: '^{{ item.key }}=' + state: present + register: configure_grub - - name: Make /tmp tmpfs mount - mount: - fstype: tmpfs - name: /tmp - src: none - opts: "defaults,nosuid,nodev" - state: present + - name: Make /tmp tmpfs mount + mount: + fstype: tmpfs + name: /tmp + src: none + opts: "defaults,nosuid,nodev" + state: present diff --git a/dropbox.yml b/dropbox.yml index 88f6341d62dcc2187177b3e71b52475e18ae7199..f98a447a545ab93dad2dc61f5b9ec44b06995c75 100644 --- a/dropbox.yml +++ b/dropbox.yml @@ -1,34 +1,34 @@ --- - hosts: all - become: no + become: false tasks: - - name: Assertions - assert: - that: - - ansible_architecture == 'x86_64' + - name: Assertions + assert: + that: + - ansible_architecture == 'x86_64' - - name: Download Dropbox tarball - get_url: - url: https://www.dropbox.com/download?plat=lnx.x86_64 - dest: '{{ ansible_user_dir }}/Downloads/dropbox-lnx.x86_64.tar.gz' - mode: 0o0644 - register: download_dropbox_tarball + - name: Download Dropbox tarball + get_url: + url: https://www.dropbox.com/download?plat=lnx.x86_64 + dest: '{{ ansible_user_dir }}/Downloads/dropbox-lnx.x86_64.tar.gz' + mode: 0o0644 + register: download_dropbox_tarball - - name: Unpack Dropbox tarball - unarchive: - copy: no - dest: '{{ ansible_user_dir }}/' - src: '{{ ansible_user_dir }}/Downloads/dropbox-lnx.x86_64.tar.gz' - creates: '{{ ansible_user_dir }}/.dropbox-dist/dropboxd' + - name: Unpack Dropbox tarball + unarchive: + copy: false + dest: '{{ ansible_user_dir }}/' + src: '{{ ansible_user_dir }}/Downloads/dropbox-lnx.x86_64.tar.gz' + creates: '{{ ansible_user_dir }}/.dropbox-dist/dropboxd' - - name: Get Python Dropbox startup script - get_url: - url: https://www.dropbox.com/download?dl=packages/dropbox.py - dest: '{{ ansible_user_dir }}/Downloads/dropbox.py' - mode: 0o0755 + - name: Get Python Dropbox startup script + get_url: + url: https://www.dropbox.com/download?dl=packages/dropbox.py + dest: '{{ ansible_user_dir }}/Downloads/dropbox.py' + mode: 0o0755 - - name: Add autostart launcher - template: - src: dropbox.py.desktop.j2 - dest: '{{ ansible_user_dir }}/.config/autostart/dropbox.py.desktop' - mode: 0o0644 + - name: Add autostart launcher + template: + src: dropbox.py.desktop.j2 + dest: '{{ ansible_user_dir }}/.config/autostart/dropbox.py.desktop' + mode: 0o0644 diff --git a/pkgs.yml b/pkgs.yml index 9287cd99f172c70176065da4e1c68020e75f4c81..60496fd10ae61f268289ab89a9e8e81bf98006bf 100644 --- a/pkgs.yml +++ b/pkgs.yml @@ -2,276 +2,279 @@ - hosts: all become: false vars: - gopath: '{{ ansible_user_dir }}/Documents/Golang' - apt: - - adb - - apache2-utils - - apt-listchanges - - apt-xapian-index - - aptitude - - bats - - bijiben - - bluez-firmware - - brasero - - cargo - - chromium-driver - - clojure - - cmake - - containerd - - cryptsetup - - deborphan - - deja-dup - - dh-make - - dnsmasq - - dnsutils - - dos2unix - - dstat - - dvd+rw-tools - - easy-rsa - - epiphany-browser - - expect - - file-roller - - firmware-intel-sound - - firmware-iwlwifi - - firmware-linux - - flatpak-builder - - ftp - - geary - - ghex - - git-annex - - git-buildpackage - - gnome-boxes - - gnome-calendar - - gnome-clocks - - gnome-core - - gnome-documents - - gnome-logs - - gnome-maps - - gnome-music - - gnome-photos - - gnome-shell-extensions-gpaste - - gnome-software - - gnome-software-plugin-flatpak - - gnome-todo - - gnome-weather - - gnupg2 - - golang - - gpgv - - graphviz - - grub-efi-amd64 - - gstreamer1.0-libav - - gstreamer1.0-vaapi - - hunspell - - hyphen-en-us - - ipcalc - - iputils-ping - - keepass2 - - kpcli - - libnss-resolve - - libnss-systemd - - libpam-mount - - libreoffice-pdfimport - - liburi-perl - - linux-image-amd64 - - liferea - - luarocks - - lynx - - meld - - mythes-en-us - - netcat-openbsd - - network-manager-gnome - - network-manager-pptp-gnome - - nodejs-legacy - - npm - - ostree - - pandoc - - plymouth-themes - - polari - - postgresql-client - - printer-driver-all - - python3-cffi - - python3-cryptography - - python3-pip - - python3-venv - - python-cffi - - python-cryptography - - python-dev - - python-pip - - python-virtualenv - - reprepro - - resolvconf - - ruby-ffi - - ruby-full - - screen - - simple-scan - - shellcheck - - strongswan-nm - - task-english - - task-hebrew - - task-hebrew-desktop - - task-hebrew-gnome-desktop - - task-gnome-desktop - - task-laptop - - task-print-server - - task-ssh-server - - telnet - - texlive-extra-utils - - texlive-fonts-recommended - - texlive-font-utils - - texlive-latex-base - - texlive-latex-extra - - texlive-luatex - - time - - tmux - - transmission-cli - - udftools - - ufw - - uidmap - - vcdimager - - vagrant - - vim-nox - - vinagre - - virtualbox-qt - - vlc - - whois - - xdg-user-dirs - go: - - github.com/giantswarm/semver-bump - - github.com/nishanths/license - - github.com/tmrts/boilr - - github.com/scaleway/scaleway-cli/scw - gem: - - bundler - - capistrano - - pry - - rake - - travis - npm: - - yo - - generator-generator - - grunt-cli - - gulp - - webcoach - - sitespeed.io - pip2: - - ansible - - ansible-container - - ansible-lint - - bcrypt - - boto - - boto3 - - docker-py - - gordon - - molecule - - netaddr - - passlib - - python-vagrant - - testinfra - pip3: - - awscli - - awslogs - - docker-compose - - Fabric3 - - flake8 - - httpie - - parse - - pelican - - pipenv - - piprot - - pre-commit - - proselint - - pur - - selenium - - sh - - template - - tox - - twine - - yapf - cargo: - - rustfmt + gopath: |- + {{ ansible_user_dir }}/Documents/Golang + apt: + - adb + - apache2-utils + - apt-listchanges + - apt-xapian-index + - aptitude + - bats + - bijiben + - bluez-firmware + - brasero + - cargo + - chromium-driver + - clojure + - cmake + - containerd + - cryptsetup + - deborphan + - deja-dup + - dh-make + - dnsmasq + - dnsutils + - dos2unix + - dstat + - dvd+rw-tools + - easy-rsa + - epiphany-browser + - expect + - file-roller + - firmware-intel-sound + - firmware-iwlwifi + - firmware-linux + - flatpak-builder + - ftp + - geary + - ghex + - git-annex + - git-buildpackage + - gnome-boxes + - gnome-calendar + - gnome-clocks + - gnome-core + - gnome-documents + - gnome-logs + - gnome-maps + - gnome-music + - gnome-photos + - gnome-shell-extensions-gpaste + - gnome-software + - gnome-software-plugin-flatpak + - gnome-todo + - gnome-weather + - gnupg2 + - golang + - gpgv + - graphviz + - grub-efi-amd64 + - gstreamer1.0-libav + - gstreamer1.0-vaapi + - hunspell + - hyphen-en-us + - ipcalc + - iputils-ping + - keepass2 + - kpcli + - libnss-resolve + - libnss-systemd + - libpam-mount + - libreoffice-pdfimport + - liburi-perl + - linux-image-amd64 + - liferea + - luarocks + - lynx + - meld + - mythes-en-us + - netcat-openbsd + - network-manager-gnome + - network-manager-pptp-gnome + - nodejs-legacy + - npm + - ostree + - pandoc + - plymouth-themes + - polari + - postgresql-client + - printer-driver-all + - python3-cffi + - python3-cryptography + - python3-pip + - python3-venv + - python-cffi + - python-cryptography + - python-dev + - python-pip + - python-virtualenv + - reprepro + - resolvconf + - ruby-ffi + - ruby-full + - screen + - simple-scan + - shellcheck + - strongswan-nm + - task-english + - task-hebrew + - task-hebrew-desktop + - task-hebrew-gnome-desktop + - task-gnome-desktop + - task-laptop + - task-print-server + - task-ssh-server + - telnet + - texlive-extra-utils + - texlive-fonts-recommended + - texlive-font-utils + - texlive-latex-base + - texlive-latex-extra + - texlive-luatex + - time + - tmux + - transmission-cli + - udftools + - ufw + - uidmap + - vcdimager + - vagrant + - vim-nox + - vinagre + - virtualbox-qt + - vlc + - whois + - xdg-user-dirs + go: + - github.com/giantswarm/semver-bump + - github.com/nishanths/license + - github.com/tmrts/boilr + - github.com/scaleway/scaleway-cli/scw + gem: + - bundler + - capistrano + - pry + - rake + - travis + npm: + - yo + - generator-generator + - grunt-cli + - gulp + - webcoach + - sitespeed.io + pip2: + - ansible + - ansible-container + - ansible-lint + - bcrypt + - boto + - boto3 + - docker-py + - gordon + - molecule + - netaddr + - passlib + - python-vagrant + - testinfra + pip3: + - awscli + - awslogs + - docker-compose + - Fabric3 + - flake8 + - httpie + - parse + - pelican + - pipenv + - piprot + - pre-commit + - proselint + - pur + - selenium + - sh + - template + - tox + - twine + - yapf + cargo: + - rustfmt tasks: - - name: Assertions - assert: - that: - - ansible_pkg_mgr == 'apt' + - name: Assertions + assert: + that: + - ansible_pkg_mgr == 'apt' - - name: apt install - when: apt is iterable - become: yes - become_user: root - apt: - name: '{{ apt }}' - state: present - purge: yes - force: yes - update_cache: yes - cache_valid_time: 3600 + - name: apt install + when: apt is iterable + become: true + become_user: root + apt: + name: '{{ apt }}' + state: present + purge: true + force: true + update_cache: true + cache_valid_time: 3600 - - name: Create the GOPATH directory - file: - path: '{{ gopath }}' - state: directory + - name: Create the GOPATH directory + file: + path: '{{ gopath }}' + state: directory - - name: go get - when: go is iterable - command: 'go get -u {{ go|join(" ") }}' - register: go_get - changed_when: "'get' in go_get" - environment: - GOPATH: '{{ gopath }}' + - name: go get + when: go is iterable + command: 'go get -u {{ go|join(" ") }}' + register: go_get + changed_when: "'get' in go_get" + environment: + GOPATH: '{{ gopath }}' - - name: gem install - with_items: '{{ gem }}' - when: gem is iterable - become: yes - become_user: root - gem: - name: '{{ item }}' - state: present - include_dependencies: yes + - name: gem install + with_items: '{{ gem }}' + when: gem is iterable + become: true + become_user: root + gem: + name: '{{ item }}' + state: present + include_dependencies: true - - name: Update npm - become: yes - become_user: root - npm: - global: yes - name: npm - state: present - version: '>=5' + - name: Update npm + become: true + become_user: root + npm: + global: true + name: npm + state: present + version: '>=5' - - name: npm install - with_items: '{{ npm }}' - when: npm is iterable - become: yes - become_user: root - npm: - global: yes - name: '{{ item }}' - state: present + - name: npm install + with_items: '{{ npm }}' + when: npm is iterable + become: true + become_user: root + npm: + global: true + name: '{{ item }}' + state: present - - name: pip2 install - when: pip2 is iterable - become: yes - become_user: root - pip: - name: '{{ pip2 }}' - state: present - execuable: pip2 + - name: pip2 install + when: pip2 is iterable + become: true + become_user: root + pip: + name: '{{ pip2 }}' + state: present + execuable: pip2 - - name: pip3 install - when: pip3 is iterable - become: yes - become_user: root - pip: - name: '{{ pip3 }}' - state: present - executable: pip3 + - name: pip3 install + when: pip3 is iterable + become: true + become_user: root + pip: + name: '{{ pip3 }}' + state: present + executable: pip3 - - name: cargo install - when: cargo is iterable - become: no - command: '/usr/bin/cargo install {{ cargo|join(" ") }}' - register: cargo_install - failed_when: cargo_install.rc > 0 and not 'already exists in destination' in cargo_install.stderr - changed_when: cargo_install.rc == 0 + - name: cargo install + when: cargo is iterable + become: false + command: '/usr/bin/cargo install {{ cargo|join(" ") }}' + register: cargo_install + failed_when: >- + cargo_install.rc > 0 and + not 'already exists in destination' in cargo_install.stderr + changed_when: cargo_install.rc == 0 diff --git a/skype.yml b/skype.yml index eca910d47308926c1c04fb76364c8af381d5e725..15d83a5bc1bfe694f4cdcfa8642a49fc2d4b9ee4 100644 --- a/skype.yml +++ b/skype.yml @@ -3,30 +3,32 @@ become: yes become_user: root tasks: - - name: Assertions - assert: - that: - - ansible_architecture in [ 'x86_64', 'x86' ] - - ansible_pkg_mgr == 'apt' + - name: Assertions + assert: + that: + - ansible_architecture in [ 'x86_64', 'x86' ] + - ansible_pkg_mgr == 'apt' - - name: APT install Flatpak - apt: - name: flatpak - state: present - update_cache: yes - cache_valid_time: 3600 + - name: APT install Flatpak + apt: + name: flatpak + state: present + update_cache: true + cache_valid_time: 3600 - - name: Add Flathub repo - become: False - command: | - flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo --user - changed_when: False + - name: Add Flathub repo + become: false + # yamllint disable-line rule:line-length + command: flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo --user + changed_when: false - - name: Install - become: False - command: | - flatpak install --user --assumeyes flathub com.skype.Client - register: skype_flatpak_install - changed_when: | - 'Installing' in skype_flatpak_install.stdout - failed_when: skype_flatpak_install.rc|int > 0 and 'already installed' not in skype_flatpak_install.stderr + - name: Install + become: false + # yamllint disable-line rule:line-length + command: flatpak install --user --assumeyes flathub com.skype.Client + register: skype_flatpak_install + changed_when: |- + 'Installing' in skype_flatpak_install.stdout + failed_when: >- + skype_flatpak_install.rc|int > 0 and + 'already installed' not in skype_flatpak_install.stderr diff --git a/slack.yml b/slack.yml index c417b71494ab9cacfd4f674cec01cc8b7f8fb7ab..5537fc84744c6023ec473ab1afe8f9c7202a4e6b 100644 --- a/slack.yml +++ b/slack.yml @@ -1,32 +1,34 @@ --- - hosts: all - become: yes + become: true become_user: root tasks: - - name: Assertions - assert: - that: - - ansible_architecture in [ 'x86_64', 'x86' ] - - ansible_pkg_mgr == 'apt' + - name: Assertions + assert: + that: + - ansible_architecture in [ 'x86_64', 'x86' ] + - ansible_pkg_mgr == 'apt' - - name: APT install Flatpak - apt: - name: flatpak - state: present - update_cache: yes - cache_valid_time: 3600 + - name: APT install Flatpak + apt: + name: flatpak + state: present + update_cache: true + cache_valid_time: 3600 - - name: Add Flathub repo - become: False - command: | - flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo --user - changed_when: False + - name: Add Flathub repo + become: false + # yamllint disable-line rule:line-length + command: flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo --user + changed_when: false - - name: Install - become: False - command: | - flatpak install --user --assumeyes flathub com.slack.Slack - register: slack_flatpak_install - changed_when: | - 'Installing' in slack_flatpak_install.stdout - failed_when: slack_flatpak_install.rc|int > 0 and 'already installed' not in slack_flatpak_install.stderr + - name: Install + become: false + # yamllint disable-line rule:line-length + command: flatpak install --user --assumeyes flathub com.slack.Slack + register: slack_flatpak_install + changed_when: | + 'Installing' in slack_flatpak_install.stdout + failed_when: >- + slack_flatpak_install.rc|int > 0 and + 'already installed' not in slack_flatpak_install.stderr diff --git a/templates/landrush.service.j2 b/templates/landrush.service.j2 index 42d7eb8f3d1b34539923cbbf99a3910a3f20d120..0a0db5b7ca89108cc6ecb86342cee22e110e08c0 100644 --- a/templates/landrush.service.j2 +++ b/templates/landrush.service.j2 @@ -2,6 +2,6 @@ Description=Vagrant Landrsuh DNS server AssertPathIsDirectory=/home/{{ ansible_env.SUDO_USER }} -[Service] -Type=forking +[Service] +Type=forking ExecStart=/usr/bin/vagrant landrush start diff --git a/vscode.yml b/vscode.yml index f62b55638f990cb10b3cefede3320d0377943361..e9298065699d319dd441ef8c0c33b92ac00fcadb 100644 --- a/vscode.yml +++ b/vscode.yml @@ -1,29 +1,30 @@ --- - hosts: all - become: yes + become: true become_user: root tasks: - - name: Assertions - assert: - that: + - name: Assertions + assert: + that: - ansible_architecture == 'x86_64' - ansible_pkg_mgr == 'apt' - - name: Add repo key - apt_key: + - name: Add repo key + apt_key: url: https://packages.microsoft.com/keys/microsoft.asc state: present - - name: Add repo - apt_repository: + - name: Add repo + apt_repository: + # yamllint disable-line rule:line-length repo: deb [arch=amd64] http://packages.microsoft.com/repos/vscode stable main state: present - update_cache: True + update_cache: true - - name: APT install - apt: + - name: APT install + apt: name: code state: present - install_recommends: False - update_cache: True + install_recommends: false + update_cache: true cache_valid_time: 3600 diff --git a/workstation.yml b/workstation.yml index 05032345b0d1e119df31b092a0658b670b0c8deb..45772066ea37ce088f63ab250a871a8bd8c308d0 100644 --- a/workstation.yml +++ b/workstation.yml @@ -2,73 +2,80 @@ - include: desktop.yml - include: pkgs.yml - hosts: all - become: yes + become: true become_user: root vars: - docker_graph_directory: '/home/{{ ansible_env.SUDO_USER }}/.bind_mounts/docker' + docker_graph_directory: |- + /home/{{ ansible_env.SUDO_USER }}/.bind_mounts/docker + handlers: - - name: Systemd daemon reload - systemd: - daemon_reload: yes + - name: Systemd daemon reload + systemd: + daemon_reload: true - - name: Restart Docker - service: + - name: Restart Docker + service: name: docker state: restarted tasks: - - name: Assertions - assert: - that: - - ansible_pkg_mgr == 'apt' - - ansible_service_mgr == 'systemd' - - ansible_architecture == 'x86_64' - - ansible_version.full | version_compare('2.4', '>=') - - - name: APT install - with_items: - - network-manager - - docker-ce - - ufw - - libdvdcss2 - - vagrant - - dnsmasq - - resolvconf - - libnotify-bin - apt: - name: '{{ item }}' - state: present - update_cache: yes - cache_valid_time: 3600 - - - name: Set NetworkManager to ignore some interfaces - ini_file: - dest: /etc/NetworkManager/NetworkManager.conf - section: keyfile - option: unmanaged-devices - value: interface-name:docker*;interface-name:vboxnet*;interface-name:nspawnbr*;interface-name:lxcbr0;interface-name:veth* - state: present - - - name: Allow local bridges access through the firewall - with_items: + - name: Assertions + assert: + that: + - ansible_pkg_mgr == 'apt' + - ansible_service_mgr == 'systemd' + - ansible_architecture == 'x86_64' + - ansible_version.full | version_compare('2.4', '>=') + + - name: APT install + with_items: + - network-manager + - docker-ce + - ufw + - libdvdcss2 + - vagrant + - dnsmasq + - resolvconf + - libnotify-bin + apt: + name: '{{ item }}' + state: present + update_cache: true + cache_valid_time: 3600 + + - name: Set NetworkManager to ignore some interfaces + ini_file: + dest: /etc/NetworkManager/NetworkManager.conf + section: keyfile + option: unmanaged-devices + value: >- + interface-name:docker*; + interface-name:vboxnet*; + interface-name:nspawnbr*; + interface-name:lxcbr0; + interface-name:veth*; + state: present + + - name: Allow local bridges access through the firewall + with_items: - docker0 - vboxnet0 - nspawnbr0 - lxcbr0 - ufw: + ufw: direction: in interface: '{{ item }}' rule: allow - - name: Add user to the docker group - user: + - name: Add user to the docker group + user: name: '{{ ansible_env.SUDO_USER }}' groups: docker - append: True + append: true state: present - - name: Create Docker graph directory - with_items: + - name: Create Docker graph directory + with_items: - path: '{{ docker_graph_directory|basename }}' owner: '{{ ansible_env.SUDO_USER }}' group: '{{ ansible_env.SUDO_USER }}' @@ -77,96 +84,98 @@ owner: root group: root mode: 0o0711 - file: + file: path: '{{ item.path }}' owner: '{{ item.owner }}' group: '{{ item.group }}' mode: '{{ item.mode }}' state: directory - notify: - - Restart Docker + notify: + - Restart Docker - - name: Configure Docker graph directory - copy: + - name: Configure Docker graph directory + copy: content: "{{ {'data-root': docker_graph_directory}|to_nice_json }}" dest: /etc/docker/daemon.json owner: root group: root mode: 0o0644 - notify: - - Restart Docker - - - name: Get Docker graph directory mountpoint - command: df {{ docker_graph_directory }} - register: docker_graph_df - changed_when: False - - - name: Create Systemd configuration override directories - with_items: - - docker.service - - dnsmasq.service - file: - path: '/etc/systemd/system/{{ item }}.d/' - owner: root - group: root - mode: 0o0755 - state: directory - - - name: Override docker.service Systemd configuration - template: - src: docker.service.d_Assertions.conf.j2 - dest: /etc/systemd/system/docker.service.d/Assertions.conf - owner: root - group: root - mode: 0o0644 - notify: - - Systemd daemon reload - - - name: Override dnsmasq.service Systemd configuration - template: - src: dnsmasq.service.d_before-systemd-resovled.conf - dest: /etc/systemd/system/dnsmasq.service.d/before-systemd-resovled.conf - owner: root - group: root - mode: 0o0644 - notify: - - Systemd daemon reload - - - name: Install Vagrant plugins - become: False - with_items: - - landrush - - vagrant-vbguest - - vagrant-gatling-rsync - command: 'vagrant plugin install {{ item }}' - changed_when: False - - - name: Get Leiningen - get_url: + notify: + - Restart Docker + + - name: Get Docker graph directory mountpoint + command: df {{ docker_graph_directory }} + register: docker_graph_df + changed_when: false + + - name: Create Systemd configuration override directories + with_items: + - docker.service + - dnsmasq.service + file: + path: '/etc/systemd/system/{{ item }}.d/' + owner: root + group: root + mode: 0o0755 + state: directory + + - name: Override docker.service Systemd configuration + template: + src: docker.service.d_Assertions.conf.j2 + dest: /etc/systemd/system/docker.service.d/Assertions.conf + owner: root + group: root + mode: 0o0644 + notify: + - Systemd daemon reload + + - name: Override dnsmasq.service Systemd configuration + template: + src: dnsmasq.service.d_before-systemd-resovled.conf + dest: /etc/systemd/system/dnsmasq.service.d/before-systemd-resovled.conf + owner: root + group: root + mode: 0o0644 + notify: + - Systemd daemon reload + + - name: Install Vagrant plugins + become: false + with_items: + - landrush + - vagrant-vbguest + - vagrant-gatling-rsync + command: 'vagrant plugin install {{ item }}' + changed_when: false + + - name: Get Leiningen + get_url: + # yamllint disable-line rule:line-length url: https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein dest: /usr/local/bin/lein owner: root group: root mode: 0o0755 - - name: Install Leiningen - become: False - command: lein - register: install_leiningen - changed_when: "'Downloading Leiningen' in install_leiningen.stdout" + - name: Install Leiningen + become: false + command: lein + register: install_leiningen + changed_when: "'Downloading Leiningen' in install_leiningen.stdout" - - name: Download Packer zip - get_url: + - name: Download Packer zip + get_url: + # yamllint disable-line rule:line-length url: https://releases.hashicorp.com/packer/1.0.2/packer_1.0.2_linux_amd64.zip dest: /root/packer.zip owner: root group: root mode: 0o0644 - - name: Unarchive Packer zip - unarchive: + - name: Unarchive Packer zip + unarchive: src: /root/packer.zip dest: /usr/local/bin/ - remote_src: True + remote_src: true owner: root group: root