Home Development machine setup
Post
Cancel

Development machine setup

Development Setup

In this guide I will provice information on how I setup my development environment. I was using WSL 2 for long, but as my demand for communicating between multiple Virtual machines. My lab consists of the following machines:

Machine nameOSPurpose
Code: alma09.lab.localAlma Linux 9Ansible control node / git / git signing profiles
Code: win2019.lab.localwindows Server 2019PowerShell / git / git signing profiles
almatest01.lab.localAlma Linux 9Ansible Test node
windc01.lab.localWindows Server 2019Ansible Test node and LAB DC


Setup

  • Install linux vm on hyper-v (or other) - At installation choose container tools and set hostname to alma09.lab.local (example)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    
      ```bash
      eval NEW_USER_NAME=dev-ansible
      sudo yum upgrade -y && sudo yum update -y
      echo /etc/sudoers.d/$NEW_USER_NAME >> $NEW_USER_NAME ALL=(ALL) NOPASSWD:ALL
      sudo useradd $NEW_USER_NAME
      passwd $NEW_USER_NAME
      ```
    
      - Then Setup the env for the new user
    
      ```bash
      eval NEW_USER_NAME=dev-ansible
      mkdir --parents ~/github ~/github/ansible_repos  ~/github/ansible_roles  ~/github/repo ~/.ssh
      touch ~/.ssh/authorized_keys
      ```
    

To generate a GPG key you can do the following:

1
2
3
4
5
6
7
8
sudo yum install pinentry
gpg --full-generate-key
# NEEDS TO BE GITHUB USER AND MAIL + minimum 4096 bits
gpg --list-secret-keys --keyid-format=long
# the keyid is the first after sec  rsa4096/KEYIDHERE 20xx
gpg --armor --export keyid
# upload to github
# to sign commits git commit -s -S -m "Code update message"

The Ansible01 machines has been setup so that I can connect through VS: Code towards that. I have setup ssh and gpg keys so that I can sign my commits towards Github. My ~/.gitconfig file has the following setup:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[user]
        email = redacted
        name = redacted
        signingkey = redacted
[commit]
        gpgsign = true

[alias]
        c = commit -s -S

[trailer "sign"]
        key = "Signed-off-by:"
        ifmissing = add
        ifexist =doNothing
        command= echo "$(git config user.name) <$(git config user.email>"
  • In your .bash_profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
eval NEW_USER=kit-ansible

#CONFIGS FILES
cat <<EOT >> ~/.gnupg/gpg.conf
default-key [GPG-KEY-ID]
use-agent
EOT

cat <<EOT >> ~/.gnupg/gpg-agent.conf 
use-standard-socket
default-cache-ttl 600
write-env-file /Users/$NEW_USER/.gnupg/gpg-agent-info
pinentry-program /usr/bin/pinentry
EOT

cat <<EOT >> ~/.bash_profile
# SSH AGENT
eval $(ssh-agent)
# ANSIBLE SETTINGS:
eval DEFAULT_ROLES_PATH=~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:~/github/ansible_roles
export GPG_TTY=$(tty)
[ -f ~/.gnupg/gpg-agent-info ] && source ~/.gnupg/gpg-agent-info

if [ -S "${GPG_AGENT_INFO%%:*}" ]; then
        export GPG_AGENT_INFO
else
      eval $( gpg-agent --daemon --options ~/.gnupg/gpg-agent.conf --write-env-file ~/.gnupg/gpg-agent-info )
fi
EOT
#REFRESH
killall gpg-agent
. ~/.bash_profile

This post is licensed under CC BY 4.0 by the author.