Browse Source

hosts: configure /etc/hosts

master
Maxim Likhachev 4 years ago
parent
commit
08243280a9
  1. 37
      Makefile
  2. 34
      README.md
  3. 8
      playbook.yml
  4. 4
      roles/hosts/defaults/main.yml
  5. 14
      roles/hosts/tasks/main.yml
  6. 2
      roles/hosts/templates/hosts.j2

37
Makefile

@ -1,23 +1,42 @@ @@ -1,23 +1,42 @@
HOMEBREW_CASK_OPTS = ""
ANSIBLE = ansible-playbook --connection=local --ask-become-pass --inventory localhost, --limit localhost
all: doc_silent local
help: ## Display this help.
@awk 'BEGIN { \
FS = ":.*##"; \
printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n" \
} \
/^[a-zA-Z_-]+:.*?##/ { \
printf " \033[36m%-12s\033[0m %s\n", $$1, $$2 \
} \
END { \
print \
}' \
$(MAKEFILE_LIST)
all: doc_silent ## Apply all roles.
$(ANSIBLE) playbook.yml
doc:
readme: doc
doc: ## Generate README.md.
scripts/doc.sh | tee README.md
doc_silent:
scripts/doc.sh > README.md
gentoo:
$(ANSIBLE) -t gentoo playbook.yml
hosts: ## Update /etc/hosts files.
$(ANSIBLE) -t hosts playbook.yml
macos:
$(ANSIBLE) -t macos playbook.yml
fonts: ## Install fonts.
$(ANSIBLE) -t fonts playbook.yml
local:
$(ANSIBLE) playbook.yml
gentoo: doc_silent hosts ## Configure Calculate Linux.
$(ANSIBLE) -t gentoo playbook.yml
macos: doc_silent hosts ## Configure MacOS.
HOMEBREW_CASK_OPTS=$(HOMEBREW_CASK_OPTS) $(ANSIBLE) -t macos playbook.yml
requirements:
requirements: ## Install requirements.
ansible-galaxy install -r requirements.yml
pip3 install --user -r requirements.txt

34
README.md

@ -29,6 +29,7 @@ $ make @@ -29,6 +29,7 @@ $ make
- [aria2](https://aria2.github.io/) - Download with resuming and segmented downloading.
- [bash](https://www.gnu.org/software/bash/) - Bourne-Again SHell, a UNIX command interpreter.
- [bat](https://github.com/sharkdp/bat) - Clone of cat(1) with syntax highlighting and Git integration.
- [coreutils](https://www.gnu.org/software/coreutils) - GNU File, Shell, and Text utilities.
- [curl](https://curl.haxx.se/) - Get a file from an HTTP, HTTPS or FTP server.
- [dfc](https://projects.gw-computing.net/projects/dfc) - Display graphs and colors of file system space/usage.
@ -38,11 +39,14 @@ $ make @@ -38,11 +39,14 @@ $ make
- [gawk](https://www.gnu.org/software/gawk/) - GNU awk utility.
- [ghostscript](https://www.ghostscript.com/) - Interpreter for PostScript and PDF.
- [git](https://git-scm.com) - Distributed revision control system.
- [git-delta](https://github.com/dandavison/delta) - Syntax-highlighting pager for git and diff output.
- [go](https://golang.org) - Programming language to build simple/reliable/efficient software.
- [haskell-stack](https://haskellstack.org/) - The Haskell Tool Stack.
- [hstr](https://github.com/dvorka/hstr) - Bash and zsh history suggest box.
- [imagemagick](https://www.imagemagick.org/) - Tools and libraries to manipulate images in many formats.
- [jimtcl](http://jim.tcl.tk/index.html) - Small footprint implementation of Tcl.
- [jq](https://stedolan.github.io/jq/) - Lightweight and flexible command-line JSON processor.
- [lagrange](https://gmi.skyjake.fi/lagrange/) - Desktop GUI client for browsing Geminispace.
- [neovim](https://neovim.io/) - Ambitious Vim-fork focused on extensibility and agility.
- [nnn](https://github.com/jarun/nnn) - Tiny, lightning fast, feature-packed file manager.
- [nodejs](https://nodejs.org) - Platform built on V8 to build network applications.
@ -53,6 +57,7 @@ $ make @@ -53,6 +57,7 @@ $ make
- [tcl-tk](https://tcl.tk) - GUI Toolkit for TCL Programming language.
- [tree](http://mama.indstate.edu/users/ice/tree/) - Display directories as trees (with optional color/HTML output).
- [vifm](https://vifm.info/) - Ncurses based file manager with vi like keybindings.
- [vivaldi](https://vivaldi.com) - A web browser which works without pulse-audio.
- [w3m](https://w3m.sourceforge.io/) - Pager/text based browser.
- [webp](https://developers.google.com/speed/webp/) - Image format providing lossless and lossy compression for web images.
- [wget](https://www.gnu.org/software/wget/) - Internet file retriever.
@ -61,9 +66,10 @@ $ make @@ -61,9 +66,10 @@ $ make
### Applications
- ~~[geeqie](http://www.geeqie.org/) - lightweight image viewer for Linux, BSDs and compatibles.~~
- ~~[ripgrep](https://github.com/BurntSushi/ripgrep) - Search tool like grep and The Silver Searcher.~~
- [xapian-1.2.25](https://www.xapian.org/) - Xapian Probabilistic Information Retrieval library.
- [perl-cleaner](https://www.gentoo.org/proj/en/perl/) - User land tool for cleaning up old perl installs.
- [unrar](https://www.rarlab.com/) - Extract, view, and test RAR archives.
- [buildah](https://github.com/containers/buildah) - A tool that facilitates building OCI images.
- [podman](https://github.com/containers/libpod/) - Library and podman tool for running OCI-based containers in Pods.
- [recoll](https://www.lesbonscomptes.com/recoll/) - A personal full text search package.
@ -72,12 +78,10 @@ $ make @@ -72,12 +78,10 @@ $ make
- [portage-utils](https://wiki.gentoo.org/wiki/Portage-utils) - Small and fast Portage helper tools written in C.
- [tesseract](https://github.com/tesseract-ocr) - An OCR Engine, originally developed at HP, now open source.
- [zathura](https://pwmt.org/projects/zathura/) - A document viewer.
- [tcl](https://tcl.tk) - TCL Programming language.
- [pip](https://pip.pypa.io/) - Installs python packages.
- [ccache](https://ccache.dev/) - Fast compiler cache.
- [mutt](http://www.mutt.org/) - A small but very powerful text-based mail client.
- [procmail](http://www.procmail.org/) - Mail delivery agent.
- [geeqie](http://www.geeqie.org/) - lightweight image viewer for Linux, BSDs and compatibles.
- [sxiv](https://github.com/muennich/sxiv) - Simple X Image Viewer.
- [libwebp](https://developers.google.com/speed/webp/download) - A lossy image compression format.
- [mutagen](https://github.com/quodlibet/mutagen) - Audio metadata tag reader and writer implemented in pure Python.
@ -88,11 +92,9 @@ $ make @@ -88,11 +92,9 @@ $ make
- [sshfs](https://github.com/libfuse/sshfs) - A network filesystem client to connect to SSH servers.
- [fetchmail](https://www.fetchmail.info) - Full-featured, robust, well-documented remote-mail retrieval and forwarding utility.
- [connman](https://01.org/connman) - Internet connection daemon.
- [ripgrep](https://github.com/BurntSushi/ripgrep) - Search tool like grep and The Silver Searcher.
- [ntfs3g](https://www.tuxera.com/community/open-source-ntfs-3g/) - Read-write NTFS driver for FUSE.
- [linux-firmware](https://git.kernel.org/?p=linux/kernel/git/firmware/linux-firmware.git) - Linux firmware files.
- [acpi_call](https://github.com/teleshoes/acpi_call) - A kernel module that enables you to call ACPI methods.
- [vivaldi](https://vivaldi.com) - A web browser which works without pulse-audio.
- [dmenu](https://tools.suckless.org/dmenu/) - Fast and lightweight dynamic menu for X.
- [polybar](https://polybar.github.io/) - A fast and easy-to-use status bar.
- [rofi](https://github.com/davatorium/rofi) - A window switcher, application launcher and dmenu replacement.
@ -109,50 +111,39 @@ $ make @@ -109,50 +111,39 @@ $ make
- ~~[joplin](https://joplinapp.org/) - An open source note taking and to-do application.~~
- ~~[k3d](https://k3d.io/) - Little helper to run Rancher Lab's k3s in Docker.~~
- ~~[min](https://github.com/minbrowser/min) - Minimal browser that protects privacy.~~
- ~~[pdftotext](https://www.bluem.net/en/mac/) - PDF to text convertor.~~
- ~~[quicklook-json](http://www.sagtau.com/quicklookjson.html) - QuickLook plugin to preview JSON files.~~
- ~~[ripgrep](https://github.com/BurntSushi/ripgrep) - Search tool like grep and The Silver Searcher.~~
- ~~[sshfs](https://github.com/libfuse/sshfs) - File system client based on SSH File Transfer Protocol.~~
- ~~[tcl](https://tcl.tk) - TCL Programming language.~~
- ~~[terraform](https://www.terraform.io/) - Tool to build, change, and version infrastructure.~~
- ~~[terraform-docs](https://github.com/terraform-docs/terraform-docs) - Tool to generate documentation from Terraform modules.~~
- ~~[terraform-ls](https://github.com/hashicorp/terraform-ls) - Terraform Language Server.~~
- ~~[terragrunt](https://terragrunt.gruntwork.io/) - Thin wrapper for Terraform.~~
- ~~[vagrant](https://www.vagrantup.com/) - Development environment.~~
- ~~[virtualbox](https://www.virtualbox.org/) - Free and open-source hosted hypervisor for x86 virtualization.~~
- ~~[virtualbox-extension-pack](https://www.virtualbox.org/) - AMD64/Intel64 and x86 virtualization.~~
- ~~[xmind-zen](https://www.xmind.net/zen/) - Mind-mapping tool.~~
- [android-file-transfer](https://www.android.com/filetransfer/) - Android File Transfer.
- [ansible](https://www.ansible.com/) - Automate deployment, configuration, and upgrading.
- [ansible-lint](https://github.com/ansible/ansible-lint/) - Checks ansible playbooks for practices and behaviour.
- [azure-cli](https://docs.microsoft.com/cli/azure/overview) - Microsoft Azure CLI.
- [bat](https://github.com/sharkdp/bat) - Clone of cat(1) with syntax highlighting and Git integration.
- [brave-browser](https://brave.com/) - Brave web browser.
- [dive](https://github.com/wagoodman/dive) - Tool for exploring each layer in a docker image.
- [djvu2pdf](https://0x2a.at/site/projects/djvu2pdf/) - Small tool to convert Djvu files to PDF files.
- [firefox](https://www.mozilla.org/ru/firefox/) - Mozilla Firefox.
- [git-cal](https://github.com/k4rthik/git-cal) - GitHub-like contributions calendar but on the command-line.
- [git-delta](https://github.com/dandavison/delta) - Syntax-highlighting pager for git and diff output.
- [glow](https://github.com/charmbracelet/glow) - Render markdown on the CLI.
- [hadolint](https://github.com/hadolint/hadolint) - Smarter Dockerfile linter to validate best practices.
- [hlint](https://github.com/ndmitchell/hlint) - Haskell source code suggestions.
- [htop](https://hisham.hm/htop/) - Improved top (interactive process viewer).
- [hyperfine](https://github.com/sharkdp/hyperfine) - Command-line benchmarking tool.
- [iterm2](https://www.iterm2.com/) - Terminal emlator.
- [jimtcl](http://jim.tcl.tk/index.html) - Small footprint implementation of Tcl.
- [k9s](https://k9scli.io/) - Kubernetes CLI To Manage Clusters.
- [kubernetes-cli](https://kubernetes.io/) - Kubernetes command-line interface.
- [lagrange](https://gmi.skyjake.fi/lagrange/) - Desktop GUI client for browsing Geminispace.
- [min](https://github.com/minbrowser/min) - Minimal browser that protects privacy.
- [osxfuse](https://osxfuse.github.io/) - FUSE for MacOS.
- [p7zip](https://p7zip.sourceforge.io/) - 7-Zip (high compression file archiver) implementation.
- [pandoc](https://pandoc.org/) - Swiss-army knife of markup format conversion.
- [qlcolorcode](https://github.com/anthonygelibert/QLColorCode) - QuickLook plugin for source code with syntax highlighting.
- [qlmarkdown](https://github.com/toland/qlmarkdown) - QuickLook generator for Markdown files.
- [qlstephen](https://whomwah.github.io/qlstephen/) - QuickLook plugin to view plain text files without a file extension.
- [qlvideo](https://github.com/Marginal/QLVideo) - QuickLook plugin to preview video files.
- [rlwrap](https://github.com/hanslub42/rlwrap) - Readline wrapper: adds readline support to tools that lack it. Dependency of cheat.sh.
- [skype](https://www.skype.com/) - Video chat, voice call and instant messaging application.
- [telegram](https://macos.telegram.org/) - Telegram for MacOS.
- [terraform](https://www.terraform.io/) - Tool to build, change, and version infrastructure.
- [terraform-docs](https://github.com/terraform-docs/terraform-docs) - Tool to generate documentation from Terraform modules.
- [terraform-ls](https://github.com/hashicorp/terraform-ls) - Terraform Language Server.
- [tflint](https://github.com/terraform-linters/tflint) - Linter for Terraform files.
- [tfsec](https://tfsec.dev/) - Static analysis security scanner for your terraform code.
- [transmission](https://transmissionbt.com/) - BitTorrent client.
@ -162,7 +153,6 @@ $ make @@ -162,7 +153,6 @@ $ make
- [vlc](https://www.videolan.org/vlc/) - VLC media player.
- [watch](https://gitlab.com/procps-ng/procps) - Executes a program periodically, showing output fullscreen.
- [webpquicklook](https://github.com/emin/WebPQuickLook) - QuickLook plugin for WebP image files.
- [xmind-zen](https://www.xmind.net/zen/) - Mind-mapping tool.
- [xnviewmp](https://www.xnview.com/) - Image viewer.
- [youtube-dl](https://youtube-dl.org/) - Download YouTube videos from the command-line.

8
playbook.yml

@ -4,6 +4,12 @@ @@ -4,6 +4,12 @@
gather_facts: yes
hosts: all
roles:
- role: fonts
tags: fonts
- role: hosts
tags: hosts
- role: linux-gentoo
tags: gentoo
when: ansible_os_family == "Calculate"
@ -12,8 +18,6 @@ @@ -12,8 +18,6 @@
tags: macos
when: ansible_os_family == "Darwin"
- role: fonts
- role: containers
tags: containers
when: ansible_os_family == "Calculate"

4
roles/hosts/defaults/main.yml

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
host_list_url: https://someonewhocares.org/hosts/zero/hosts
host_file: /etc/hosts

14
roles/linux-gentoo/tasks/hosts.yml → roles/hosts/tasks/main.yml

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
- name: Get host list from someonewhocares.org
- name: Get host list from the Internet
uri:
url: https://someonewhocares.org/hosts/zero/hosts
url: "{{ host_list_url }}"
return_content: yes
status_code: [200, 202]
register: raw_hosts
@ -9,11 +9,17 @@ @@ -9,11 +9,17 @@
set_fact:
hosts: "{{ raw_hosts.content }}"
- name: The list of blocked hosts
debug:
var: hosts
verbosity: 2
- name: Configure /etc/hosts
become: yes
vars:
hostname: "{{ system.hostname }}"
hosts: hosts.results
template:
src: hosts.j2
dest: /etc/hosts.clt
dest: "{{ host_file }}"
mode: 0644

2
roles/linux-gentoo/templates/hosts.j2 → roles/hosts/templates/hosts.j2

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
#<localhost>
127.0.0.1 localhost
127.0.0.1 {{ hostname | default("calculate") }}
127.0.0.1 {{ lookup('env', 'HOSTNAME') }}
127.0.0.1 localhost.localdomain
255.255.255.255 broadcasthost
::1 localhost
Loading…
Cancel
Save