Coder Social home page Coder Social logo

techdufus / dotfiles Goto Github PK

View Code? Open in Web Editor NEW
253.0 4.0 42.0 538 KB

Fully automated development environment for TechDufus using ansible.

License: Apache License 2.0

Shell 21.17% Lua 45.08% Jinja 0.29% Python 33.46%
ansible neovim bash dotfiles archlinux ubuntu

dotfiles's Introduction

dotfiles-logo

commit frequency


Fully automated development environment for TechDufus on Twitch.

You can watch a quick 'tour' here on YouTube:

Automating your Dotfiles with Ansible: A Showcase

This repo is heavily influenced by ALT-F4-LLC's repo. Go check it out!

Goals

Provide fully automated Ubuntu|Arch development environment that is easy to set up and maintain.

Why Ansible?

Ansible replicates what we would do to set up a development environment pretty well. There are many automation solutions out there - I happen to enjoy using Ansible.

Requirements

Operating System

This Ansible playbook only supports Ubuntu|Arch distribution. This is by design to provide a consistent development experience across hosts.

System Upgrade

Verify your Ubuntu|Arch installation has all latest packages installed before running the playbook.

# Ubuntu
sudo apt-get update && sudo apt-get upgrade -y
# Arch
sudo pacman -Syu

NOTE: This will take some time.

Setup

all.yaml values file

The all.yaml file allows you to personalize your setup to your needs. This file will be created in the file located at ~/.dotfiles/group_vars/all.yaml after you Install this dotfiles and include your desired settings.

Below is a list of all available values. Not all are required but incorrect values will break the playbook if not properly set.

Name Type Required
git_user_email string yes
git_user_name string yes
exclude_roles array (see group_vars/all) no
ssh_key dict (see SSH Keys below) no
system_host dict (see System Hosts below) no
bash_public dict (see Environment below) no
bash_private dict (see Environment below) no

Environment

Manage environment variables by configuring the bash_public and bash_private values in values.yaml. See both values usecase below.

bash_public

The bash_public value allows you to include a dictionary of generic and unsecure key-value pairs that will be stored in a ~/.bash_public.

---
bash_public:
  MY_ENV_VAR: something

bash_private

The bash_private value allows you to include a dictionary of secure key-value pairs that will be stored in a ~/.bash_private.

---
bash_private:
  MY_ENV_VAR_SECRET: !vault |
    $ANSIBLE_VAULT;1.1;AES256
    62333533626436313366316235626561626635396233303730343332666466393561346462303163
    3666636638613437353663356563656537323136646137630a336332303030323031376164316562
    65333963633339323382938472963766303966643035303234376163616239663539366564396166
    3830376265316231630a623834333061393138306331653164626437623337366165636163306237
    3437

SSH Keys

Manage SSH keys by setting the ssh_key value in values.yaml shown as example below:

---
ssh_key:
  <filename>: !vault |
    $ANSIBLE_VAULT;1.1;AES256
    62333533626436313366316235626561626635396233303730343332666466393561346462303163
    3666636638613437483928376563656537323136646137630a336332303030323031376164316562
    65333963633339323762663865363766303966643035303234376163616239663539366564396166
    3830376265316231630a623834333061393138306331653164626437623337366165636163306237
    3437

NOTE: All ssh keys will be stored at $HOME/.ssh/<filename>.

System Hosts

Manage /etc/hosts by setting the system_host value in values.yaml.

---
system_host:
  127.0.0.1: foobar.localhost

Examples

Below includes minimal and advanced configuration examples. If you would like to see a more real world example take a look at blackglasses public configuration repository.

Minimal

Below is a minimal example of values.yaml file:

---
git_user_email: [email protected]
git_user_name: Foo Bar

Advanced

Below is a more advanced example of values.yaml file:

---
git_user_email: [email protected]
git_user_name: Foo Bar
exclude_roles:
  - slack
ssh_key: !vault |
  $ANSIBLE_VAULT;1.1;AES256
  62333533626436313366316235626561626635396233303730343332666466393561346462303163
  3666636638613437353663356563656537323136646137630a336332303030323031376164316562
  65333963633339323762663865363766303966643035303234376163616239663539366564396166
  3830376265316231630a623834333061393138306331653164626437623337366165636163306237
  3437
system_host:
  127.0.0.1: foobar.localhost
bash_public:
  MY_PUBLIC_VAR: foobar
bash_private:
  MY_SECRET_VAR: !vault |
    $ANSIBLE_VAULT;1.1;AES256
    62333533626436313366316235626561626635396233303730343332666466393561346462303163
    3666636638613437353663356563656537323136646137630a336332303030323031376164316562
    65333963633339323762663865363766303966643035303234376163616239663539366564396166
    3830376265316231630a623834333061393138306331653164626437623337366165636163306237
    3437

vault.secret

The vault.secret file allows you to encrypt values with Ansible vault and store them securely in source control. Create a file located at ~/.config/dotfiles/vault.secret with a secure password in it.

vim ~/.ansible-vault/vault.secret

To then encrypt values with your vault password use the following:

$ ansible-vault encrypt_string --vault-password-file $HOME/.ansible-vault/vault.secret "mynewsecret" --name "MY_SECRET_VAR"
$ cat myfile.conf | ansible-vault encrypt_string --vault-password-file $HOME/.ansible-vault/vault.secret --stdin-name "myfile"

NOTE: This file will automatically be detected by the playbook when running dotfiles command to decrypt values. Read more on Ansible Vault here.

Usage

Install

This playbook includes a custom shell script located at bin/dotfiles. This script is added to your $PATH after installation and can be run multiple times while making sure any Ansible dependencies are installed and updated.

This shell script is also used to initialize your environment after installing Ubuntu|Arch and performing a full system upgrade as mentioned above.

NOTE: You must follow required steps before running this command or things may become unusable until fixed.

bash -c "$(curl -fsSL https://raw.githubusercontent.com/TechDufus/dotfiles/main/bin/dotfiles)"

If you want to run only a specific role, you can specify the following bash command:

curl -fsSL https://raw.githubusercontent.com/TechDufus/dotfiles/main/bin/dotfiles | bash -s -- --tags comma,seperated,tags

Update

This repository is continuously updated with new features and settings which become available to you when updating.

To update your environment run the dotfiles command in your shell:

dotfiles

This will handle the following tasks:

  • Verify Ansible is up-to-date
  • Generate SSH keys and add to ~/.ssh/authorized_keys
  • Clone this repository locally to ~/.dotfiles
  • Verify any ansible-galaxy plugins are updated
  • Run this playbook with the values in ~/.config/dotfiles/group_vars/all.yaml

This dotfiles command is available to you after the first use of this repo, as it adds this repo's bin directory to your path, allowing you to call dotfiles from anywhere.

Any flags or arguments you pass to the dotfiles command are passed as-is to the ansible-playbook command.

For Example: Running the tmux tag with verbosity

dotfiles -t tmux -vvv

dotfiles's People

Contributors

techdufus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dotfiles's Issues

[BUG] beautiful_output plugin import of watchdog fails

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Creating new codespace on GH with this repo. Running the dotfile script from the repo root with:
./bin/dotfiles

I get this output:

[ ]  Installing Ansible 

[notice] A new release of pip is available: 23.3.2 -> 24.0
 [✓]  Installing Ansible
 [✓]  Installing Python3 Watchdog
 [✓]  Generating SSH keys
 [✓]  Cloning repository
 [✓]  Updating Galaxy
 [✓]  Running playbook
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
ERROR! Unexpected Exception, this is probably a bug: No module named 'watchdog'

my current solution is the disable the plugin in the ansible.cfg file

I verified that the watchdog is installed and can be imported from the python shell.

Expected Behavior

No response

Steps To Reproduce

No response

Environment

  • OS: Ubuntu 22.04
  • Architecture: x86

Anything else?

No response

[BUG] ARCH: No `unzip` handler is installed

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

System | Unzip win32yank.exe
  ✘ localhost [FAILED]
    Message:
      Failed to find handler for "/home/techdufus/.ansible/tmp/ansible-
      tmp-1708004294.0679557-4431-35770479633598/source". Make sure the required
      command to extract the file is installed.
      Unable to find required 'unzip' or 'unzip' binary in the path.
      Command "/usr/sbin/tar" could not handle archive: Unable to list files in
      the archive: zstd: /*stdin*\: unsupported format
      /usr/sbin/tar: Child returned status 1
      /usr/sbin/tar: Error is not recoverable: exiting now

      Command "/usr/sbin/tar" could not handle archive: Unable to list files in
      the archive: gzip: stdin has more than one entry--rest ignored
      /usr/sbin/tar: This does not look like a tar archive
      /usr/sbin/tar: Skipping to next header
      /usr/sbin/tar: Child returned status 2
      /usr/sbin/tar: Error is not recoverable: exiting now

      Command "/usr/sbin/tar" could not handle archive: Unable to list files in
      the archive: /usr/sbin/tar: This does not look like a tar archive
      /usr/sbin/tar: Skipping to next header
      /usr/sbin/tar: Exiting with failure status due to previous errors

      Unable to find required 'unzip' or 'zipinfo' binary in the path.
      Command "/usr/sbin/tar" could not handle archive: Unable to list files in
      the archive: bzip2: (stdin) is not a bzip2 file.
      /usr/sbin/tar: Child returned status 2
      /usr/sbin/tar: Error is not recoverable: exiting now

      Command "/usr/sbin/tar" could not handle archive: Unable to list files in
      the archive: xz: (stdin): File format not recognized
      /usr/sbin/tar: Child returned status 1
      /usr/sbin/tar: Error is not recoverable: exiting now
    Invocation:
      module_args:
        attributes: None
        copy: true
        creates: None
        decrypt: true
        dest: /tmp
        exclude: []
        extra_opts: []
        group: None
        include: []
        io_buffer_size: 65536
        keep_newer: false
        list_files: false
        mode: '0755'
        owner: None
        remote_src: false
        selevel: None
        serole: None
        setype: None
        seuser: None
        src: /home/techdufus/.ansible/tmp/ansible-
      tmp-1708004294.0679557-4431-35770479633598/source
        unsafe_writes: false
        validate_certs: true

Expected Behavior

No response

Steps To Reproduce

No response

Environment

  • OS:
  • Architecture:

Anything else?

No response

[BUG] mode for ansible.builtin.get_url causes error

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Thank you for sharing this repo,
In this file:
https://github.com/TechDufus/dotfiles/blob/main/roles/bash/tasks/ubuntu.yml

I had to change all the 'mode' flags to the "0755" syntax instead of 755.
I got permission problems when running the main.yml playbook

Update:
In line 21 same file:
/{{ ansible_user_dir }}/oh-my-bash.install.sh
This causing ansible trying to access a file in //$HOME
Changing it to:
"{{ ansible_user_dir }}/oh-my-bash.install.sh"

Fixes the problem

Expected Behavior

No response

Steps To Reproduce

https://github.com/TechDufus/dotfiles/blob/main/roles/bash/tasks/ubuntu.yml

Environment

  • OS: Ubuntu 22.04
  • Architecture: x86

Anything else?

Happy to create a PR if you prefer that
No response

[BUG] ARCH: TLDR role does not have handlers

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Error: ERROR! The requested handler 'Cleanup Tldr downloaded tar' was not found in either the main handlers list nor in the listening handlers list

Expected Behavior

No response

Steps To Reproduce

No response

Environment

  • OS:
  • Architecture:

Anything else?

No response

[FEATURE_REQUEST] Add Role for Updating from Github Release

Is your feature request related to a problem?

Many roles have mostly duplicate code when it comes to pulling latest releases from Github.

Solution you'd like

A single role that will take in config options / customizations for each release, and install github releases by calling this role.

Alternatives you've considered

No response

Anything else?

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.