- Add comprehensive Ansible guidelines and best practices (CLAUDE.md) - Add infrastructure inventory documentation - Add VM deployment playbooks and configurations - Add dynamic inventory plugins (libvirt_kvm, ssh_config) - Add cloud-init and preseed configurations for automated deployments - Add security-first configuration templates - Add role and setup documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
50 lines
1.4 KiB
Bash
50 lines
1.4 KiB
Bash
#!/bin/bash
|
|
# Script to configure the Debian VM with ansible user and LVM partitioning
|
|
|
|
VM_IP="192.168.122.191"
|
|
ANSIBLE_SSH_KEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILBrnivsqjhAxWYeuuvnYc3neeRRuHsr2SjeKv+Drtpu user@debian"
|
|
|
|
echo "Configuring Debian VM at $VM_IP..."
|
|
|
|
# Create ansible user
|
|
echo "Creating ansible user..."
|
|
cat << 'SETUP_SCRIPT' | ssh root@${VM_IP}
|
|
# Create ansible user
|
|
useradd -m -s /bin/bash -G sudo ansible
|
|
|
|
# Setup SSH directory
|
|
mkdir -p /home/ansible/.ssh
|
|
chmod 700 /home/ansible/.ssh
|
|
|
|
# Add SSH key
|
|
echo "$ANSIBLE_SSH_KEY" > /home/ansible/.ssh/authorized_keys
|
|
chmod 600 /home/ansible/.ssh/authorized_keys
|
|
chown -R ansible:ansible /home/ansible/.ssh
|
|
|
|
# Configure sudoers
|
|
echo "ansible ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/ansible
|
|
chmod 440 /etc/sudoers.d/ansible
|
|
|
|
# Configure SSH
|
|
cat > /etc/ssh/sshd_config.d/99-security.conf << 'SSH_CONFIG'
|
|
PermitRootLogin no
|
|
PasswordAuthentication no
|
|
PubkeyAuthentication yes
|
|
SSH_CONFIG
|
|
|
|
systemctl restart sshd
|
|
|
|
# Install required packages
|
|
apt-get update
|
|
apt-get install -y sudo vim htop tmux curl wget rsync git python3 python3-pip jq bc aide auditd chrony ufw lvm2 cloud-guest-utils
|
|
|
|
# Extend partition and configure LVM
|
|
echo "Extending root partition..."
|
|
growpart /dev/vda 1 || true
|
|
resize2fs /dev/vda1 || true
|
|
|
|
echo "Ansible user configuration complete!"
|
|
SETUP_SCRIPT
|
|
|
|
echo "Configuration complete! Test with: ssh ansible@${VM_IP}"
|