Added building Ubuntu 20.04 template
This commit is contained in:
parent
36aa9106ea
commit
09aa511791
@ -9,7 +9,9 @@ aaa ansible_host=10.8.221.200
|
||||
|
||||
## Do not edit and delete it ##
|
||||
## It need for packer templetes ##
|
||||
packer-templ
|
||||
packer-templ-debian-11-x64
|
||||
packer-templ-debian-12-x64
|
||||
packer-templ-ubuntu-24-04-x64
|
||||
## Do not edit and delete it ##
|
||||
## It need for packer templetes ##
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
#
|
||||
# For use:
|
||||
# ansible-inventory -i /root/ansible/inventories/vmware_vm_inventory.yml --list -y --output zzz.yml
|
||||
# ansible-inventory -i ~/ansible/inventories/vmware_vm_inventory.yml --list -y --output zzz.yml
|
||||
# cat zzz.yml | grep -i "guestid" | sed 's/^ config.guestId: //' | sed 's/$.*//' | sort | uniq
|
||||
#
|
||||
plugin: community.vmware.vmware_vm_inventory
|
||||
|
@ -21,7 +21,7 @@ vm_ip_search="lab.loc"
|
||||
|
||||
# ***********
|
||||
|
||||
/usr/bin/ansible-playbook /root/ansible/playbooks/os-ipxe-vmware-deploy.yml \
|
||||
/usr/bin/ansible-playbook ~/ansible/playbooks/os-ipxe-vmware-deploy.yml \
|
||||
-e "ipxe_target=$ipxe_target ipxe_net_name=$ipxe_net_name \
|
||||
vm_name=$vm_name vm_folder=$vm_folder vm_guest_id=$vm_guest_id vm_datastore=$vm_datastore vm_net_name=$vm_net_name \
|
||||
vm_ip_addr=$vm_ip_addr vm_ip_mask=$vm_ip_mask vm_ip_gw=$vm_ip_gw vm_ip_dns=$vm_ip_dns vm_ip_domain=$vm_ip_domain \
|
@ -6,4 +6,4 @@
|
||||
vars_files:
|
||||
- ~/.secret/.ansible/vars_creds.yml
|
||||
roles:
|
||||
- os-linux-prep-default
|
||||
- os-linux-prep-templ
|
@ -1,14 +0,0 @@
|
||||
---
|
||||
|
||||
- include_vars: os-pkg-list.yml
|
||||
|
||||
- name: Install from list of packages for Debian
|
||||
block:
|
||||
- name: Install from list of packages for Debian
|
||||
apt:
|
||||
state: latest
|
||||
pkg: "{{ debian_install_pkg_list }}"
|
||||
- name: Run "apt-get clean"
|
||||
apt:
|
||||
clean: yes
|
||||
when: ansible_distribution == "Debian"
|
@ -1,21 +0,0 @@
|
||||
---
|
||||
|
||||
- name: Prepare scripts for custom VMs (First start)
|
||||
block:
|
||||
- name: Copy files to remote system
|
||||
ansible.builtin.copy:
|
||||
src: files/first_start.sh
|
||||
dest: /root/first_start.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
- name: Edit /etc/rc.local
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/rc.local
|
||||
regexp: '^(exit 0.*)$'
|
||||
line: |
|
||||
/root/first_start.sh &
|
||||
$(sleep 2; chmod 755 /root/first_start.sh | sed '/chmod 755 \/root\/first_start.sh/d' -i /etc/rc.local) &
|
||||
exit 0
|
||||
|
||||
when: ansible_os_family == "Debian"
|
@ -1,45 +0,0 @@
|
||||
---
|
||||
|
||||
debian_install_pkg_list:
|
||||
- net-tools
|
||||
- mc
|
||||
- htop
|
||||
- bash-completion
|
||||
- iotop
|
||||
- iftop
|
||||
- bwm-ng
|
||||
- sysstat
|
||||
- iptraf-ng
|
||||
- iperf3
|
||||
- tcpdump
|
||||
- scsitools
|
||||
- lsscsi
|
||||
- kpartx
|
||||
- toilet
|
||||
- figlet
|
||||
- git
|
||||
- apt-transport-https
|
||||
- sysfsutils
|
||||
- curl
|
||||
- gpg
|
||||
- secure-delete
|
||||
- dnsutils
|
||||
- rpm2cpio
|
||||
- dos2unix
|
||||
- telnet
|
||||
- rsync
|
||||
- sudo
|
||||
- whois
|
||||
- pv
|
||||
- lsof
|
||||
- tmux
|
||||
- hping3
|
||||
- nload
|
||||
- parted
|
||||
- netcat-openbsd
|
||||
- wget
|
||||
- ftp
|
||||
- vim
|
||||
- rsyslog
|
||||
- iptables
|
||||
- man
|
116
ansible/roles/os-linux-prep-templ/files/.bashrc
Normal file
116
ansible/roles/os-linux-prep-templ/files/.bashrc
Normal file
@ -0,0 +1,116 @@
|
||||
# ~/.bashrc: executed by bash(1) for non-login shells.
|
||||
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
|
||||
# for examples
|
||||
|
||||
# If not running interactively, don't do anything
|
||||
case $- in
|
||||
*i*) ;;
|
||||
*) return;;
|
||||
esac
|
||||
|
||||
# by me
|
||||
shopt -s cdspell
|
||||
|
||||
# don't put duplicate lines or lines starting with space in the history.
|
||||
# See bash(1) for more options
|
||||
HISTCONTROL=ignoreboth
|
||||
|
||||
# append to the history file, don't overwrite it
|
||||
shopt -s histappend
|
||||
|
||||
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
||||
HISTSIZE=2000
|
||||
HISTFILESIZE=2000
|
||||
|
||||
# check the window size after each command and, if necessary,
|
||||
# update the values of LINES and COLUMNS.
|
||||
shopt -s checkwinsize
|
||||
|
||||
# If set, the pattern "**" used in a pathname expansion context will
|
||||
# match all files and zero or more directories and subdirectories.
|
||||
#shopt -s globstar
|
||||
|
||||
# make less more friendly for non-text input files, see lesspipe(1)
|
||||
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
||||
|
||||
# set variable identifying the chroot you work in (used in the prompt below)
|
||||
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
|
||||
debian_chroot=$(cat /etc/debian_chroot)
|
||||
fi
|
||||
|
||||
# set a fancy prompt (non-color, unless we know we "want" color)
|
||||
case "$TERM" in
|
||||
xterm-color|*-256color) color_prompt=yes;;
|
||||
esac
|
||||
|
||||
# uncomment for a colored prompt, if the terminal has the capability; turned
|
||||
# off by default to not distract the user: the focus in a terminal window
|
||||
# should be on the output of commands, not on the prompt
|
||||
force_color_prompt=yes
|
||||
|
||||
if [ -n "$force_color_prompt" ]; then
|
||||
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
||||
# We have color support; assume it's compliant with Ecma-48
|
||||
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
|
||||
# a case would tend to support setf rather than setaf.)
|
||||
color_prompt=yes
|
||||
else
|
||||
color_prompt=
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$color_prompt" = yes ]; then
|
||||
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
||||
else
|
||||
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
||||
fi
|
||||
unset color_prompt force_color_prompt
|
||||
|
||||
# If this is an xterm set the title to user@host:dir
|
||||
case "$TERM" in
|
||||
xterm*|rxvt*)
|
||||
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# enable color support of ls and also add handy aliases
|
||||
if [ -x /usr/bin/dircolors ]; then
|
||||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
||||
alias ls='ls --color=auto'
|
||||
#alias dir='dir --color=auto'
|
||||
#alias vdir='vdir --color=auto'
|
||||
|
||||
alias grep='grep --color=auto'
|
||||
#alias fgrep='fgrep --color=auto'
|
||||
#alias egrep='egrep --color=auto'
|
||||
fi
|
||||
|
||||
# colored GCC warnings and errors
|
||||
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
|
||||
|
||||
# some more ls aliases
|
||||
#alias ll='ls -l'
|
||||
#alias la='ls -A'
|
||||
#alias l='ls -CF'
|
||||
|
||||
# Alias definitions.
|
||||
# You may want to put all your additions into a separate file like
|
||||
# ~/.bash_aliases, instead of adding them here directly.
|
||||
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
|
||||
|
||||
if [ -f ~/.bash_aliases ]; then
|
||||
. ~/.bash_aliases
|
||||
fi
|
||||
|
||||
# enable programmable completion features (you don't need to enable
|
||||
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
||||
# sources /etc/bash.bashrc).
|
||||
if ! shopt -oq posix; then
|
||||
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
||||
. /usr/share/bash-completion/bash_completion
|
||||
elif [ -f /etc/bash_completion ]; then
|
||||
. /etc/bash_completion
|
||||
fi
|
||||
fi
|
143
ansible/roles/os-linux-prep-templ/files/.config/mc/ini
Normal file
143
ansible/roles/os-linux-prep-templ/files/.config/mc/ini
Normal file
@ -0,0 +1,143 @@
|
||||
[Midnight-Commander]
|
||||
verbose=true
|
||||
shell_patterns=true
|
||||
auto_save_setup=false
|
||||
preallocate_space=false
|
||||
auto_menu=false
|
||||
use_internal_view=true
|
||||
use_internal_edit=true
|
||||
clear_before_exec=true
|
||||
confirm_delete=true
|
||||
confirm_overwrite=true
|
||||
confirm_execute=false
|
||||
confirm_history_cleanup=true
|
||||
confirm_exit=false
|
||||
confirm_directory_hotlist_delete=false
|
||||
confirm_view_dir=false
|
||||
safe_delete=false
|
||||
safe_overwrite=false
|
||||
use_8th_bit_as_meta=false
|
||||
mouse_move_pages_viewer=true
|
||||
mouse_close_dialog=false
|
||||
fast_refresh=false
|
||||
drop_menus=false
|
||||
wrap_mode=true
|
||||
old_esc_mode=true
|
||||
cd_symlinks=true
|
||||
show_all_if_ambiguous=false
|
||||
use_file_to_guess_type=true
|
||||
alternate_plus_minus=false
|
||||
only_leading_plus_minus=true
|
||||
show_output_starts_shell=false
|
||||
xtree_mode=false
|
||||
file_op_compute_totals=true
|
||||
classic_progressbar=true
|
||||
use_netrc=true
|
||||
ftpfs_always_use_proxy=false
|
||||
ftpfs_use_passive_connections=true
|
||||
ftpfs_use_passive_connections_over_proxy=false
|
||||
ftpfs_use_unix_list_options=true
|
||||
ftpfs_first_cd_then_ls=true
|
||||
ignore_ftp_chattr_errors=true
|
||||
editor_fill_tabs_with_spaces=false
|
||||
editor_return_does_auto_indent=false
|
||||
editor_backspace_through_tabs=false
|
||||
editor_fake_half_tabs=true
|
||||
editor_option_save_position=true
|
||||
editor_option_auto_para_formatting=false
|
||||
editor_option_typewriter_wrap=false
|
||||
editor_edit_confirm_save=true
|
||||
editor_syntax_highlighting=true
|
||||
editor_persistent_selections=true
|
||||
editor_drop_selection_on_copy=true
|
||||
editor_cursor_beyond_eol=false
|
||||
editor_cursor_after_inserted_block=false
|
||||
editor_visible_tabs=true
|
||||
editor_visible_spaces=true
|
||||
editor_line_state=false
|
||||
editor_simple_statusbar=false
|
||||
editor_check_new_line=false
|
||||
editor_show_right_margin=false
|
||||
editor_group_undo=true
|
||||
editor_state_full_filename=true
|
||||
editor_ask_filename_before_edit=false
|
||||
nice_rotating_dash=true
|
||||
mcview_remember_file_position=false
|
||||
auto_fill_mkdir_name=true
|
||||
copymove_persistent_attr=true
|
||||
pause_after_run=0
|
||||
mouse_repeat_rate=100
|
||||
double_click_speed=250
|
||||
old_esc_mode_timeout=1000000
|
||||
max_dirt_limit=10
|
||||
num_history_items_recorded=60
|
||||
vfs_timeout=60
|
||||
ftpfs_directory_timeout=900
|
||||
ftpfs_retry_seconds=30
|
||||
fish_directory_timeout=900
|
||||
editor_tab_spacing=8
|
||||
editor_word_wrap_line_length=72
|
||||
editor_option_save_mode=0
|
||||
editor_backup_extension=~
|
||||
editor_filesize_threshold=64M
|
||||
editor_stop_format_chars=-+*\\,.;:&>
|
||||
mcview_eof=
|
||||
skin=default
|
||||
|
||||
[Layout]
|
||||
message_visible=0
|
||||
keybar_visible=1
|
||||
xterm_title=1
|
||||
output_lines=0
|
||||
command_prompt=1
|
||||
menubar_visible=1
|
||||
free_space=1
|
||||
horizontal_split=0
|
||||
vertical_equal=1
|
||||
left_panel_size=66
|
||||
horizontal_equal=1
|
||||
top_panel_size=1
|
||||
|
||||
[Misc]
|
||||
timeformat_recent=%b %e %H:%M
|
||||
timeformat_old=%b %e %Y
|
||||
ftp_proxy_host=gate
|
||||
ftpfs_password=anonymous@
|
||||
display_codepage=UTF-8
|
||||
source_codepage=Other_8_bit
|
||||
autodetect_codeset=
|
||||
spell_language=en
|
||||
clipboard_store=
|
||||
clipboard_paste=
|
||||
|
||||
[Colors]
|
||||
base_color=
|
||||
xterm=
|
||||
color_terminals=
|
||||
|
||||
[Panels]
|
||||
show_mini_info=true
|
||||
kilobyte_si=false
|
||||
mix_all_files=false
|
||||
show_backups=true
|
||||
show_dot_files=true
|
||||
fast_reload=false
|
||||
fast_reload_msg_shown=false
|
||||
mark_moves_down=true
|
||||
reverse_files_only=true
|
||||
auto_save_setup_panels=false
|
||||
navigate_with_arrows=false
|
||||
panel_scroll_pages=true
|
||||
panel_scroll_center=false
|
||||
mouse_move_pages=true
|
||||
filetype_mode=true
|
||||
permission_mode=false
|
||||
torben_fj_mode=false
|
||||
quick_search_mode=2
|
||||
select_flags=7
|
||||
|
||||
[Panelize]
|
||||
Find *.orig after patching=find . -name \\*.orig -print
|
||||
Find SUID and SGID programs=find . \\( \\( -perm -04000 -a -perm /011 \\) -o \\( -perm -02000 -a -perm /01 \\) \\) -print
|
||||
Find rejects after patching=find . -name \\*.rej -print
|
||||
Modified git files=git ls-files --modified
|
@ -0,0 +1,35 @@
|
||||
[New Left Panel]
|
||||
display=listing
|
||||
reverse=false
|
||||
case_sensitive=false
|
||||
exec_first=false
|
||||
sort_order=name
|
||||
list_mode=full
|
||||
brief_cols=2
|
||||
user_format=half type name | size | perm
|
||||
user_status0=half type name | size | perm
|
||||
user_status1=half type name | size | perm
|
||||
user_status2=half type name | size | perm
|
||||
user_status3=half type name | size | perm
|
||||
user_mini_status=false
|
||||
list_format=full
|
||||
|
||||
[New Right Panel]
|
||||
display=listing
|
||||
reverse=false
|
||||
case_sensitive=false
|
||||
exec_first=false
|
||||
sort_order=name
|
||||
list_mode=full
|
||||
brief_cols=2
|
||||
user_format=half type name | size | perm
|
||||
user_status0=half type name | size | perm
|
||||
user_status1=half type name | size | perm
|
||||
user_status2=half type name | size | perm
|
||||
user_status3=half type name | size | perm
|
||||
user_mini_status=false
|
||||
list_format=full
|
||||
|
||||
[Dirs]
|
||||
current_is_left=false
|
||||
other_dir=/
|
@ -10,8 +10,6 @@ resize2fs /dev/vg01/root
|
||||
echo "Generete new machine-id"
|
||||
rm /etc/machine-id
|
||||
systemd-machine-id-setup
|
||||
echo "Clean all logs"
|
||||
find /var/log -type f,l | xargs rm -f
|
||||
|
||||
echo "Recreate new SSHd keys"
|
||||
rm -f /etc/ssh/ssh_host_*
|
||||
@ -81,4 +79,7 @@ rm /root/first_start.sh
|
||||
|
||||
sleep 5
|
||||
|
||||
echo "Clean all logs"
|
||||
find /var/log -type f,l | xargs rm -f
|
||||
|
||||
reboot
|
@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "First start VM"
|
||||
echo "Resize root partition..."
|
||||
parted /dev/sda resizepart 2 100%
|
||||
pvresize /dev/sda2
|
||||
lvextend -y -f -l +100%FREE /dev/vg01/root
|
||||
resize2fs /dev/vg01/root
|
||||
|
||||
echo "Generete new machine-id"
|
||||
rm /etc/machine-id
|
||||
systemd-machine-id-setup
|
||||
|
||||
echo "Recreate new SSHd keys"
|
||||
rm -f /etc/ssh/ssh_host_*
|
||||
dpkg-reconfigure openssh-server --force -f noninteractive
|
||||
|
||||
echo "Make right /etc/network/interfaces"
|
||||
rm -rf /etc/netplan/*
|
||||
|
||||
iface=`ip a | grep 'global' | awk {'print $7'}`
|
||||
ip_add=`ifconfig | grep -E "inet(.*)broadcast" | awk {'print $2'}`
|
||||
ip_netm=`ifconfig | grep -E "inet(.*)broadcast" | awk {'print $4'}`
|
||||
ip_gw=`ip r l | grep 'default' | awk {'print $3'}`
|
||||
|
||||
echo "
|
||||
# This file describes the network interfaces available on your system
|
||||
# and how to activate them. For more information, see interfaces(5).
|
||||
|
||||
source /etc/network/interfaces.d/*
|
||||
|
||||
# The loopback network interface
|
||||
auto lo
|
||||
iface lo inet loopback
|
||||
|
||||
# The primary network interface
|
||||
auto $iface
|
||||
allow-hotplug $iface
|
||||
iface $iface inet static
|
||||
address $ip_add
|
||||
netmask $ip_netm
|
||||
gateway $ip_gw
|
||||
" > /etc/network/interfaces
|
||||
|
||||
|
||||
echo "Create hostname and hosts"
|
||||
|
||||
ipaddr=$(ip a | grep "scope global" | awk '{print $2}' | sed -r 's/\/.+//')
|
||||
host_name=$(hostname -f)
|
||||
host_shot_name=$(hostname -s)
|
||||
|
||||
echo $host_name > /etc/hostname
|
||||
echo "127.0.0.1 localhost" > /etc/hosts
|
||||
echo "$ipaddr $host_name $host_shot_name" >> /etc/hosts
|
||||
|
||||
|
||||
systemctl enable networking.service
|
||||
systemctl disable systemd-networkd-wait-online.service
|
||||
systemctl disable systemd-networkd.service
|
||||
|
||||
systemctl disable multipathd.service
|
||||
systemctl disable ModemManager.service
|
||||
|
||||
apt -y purge cloud-init unattended-upgrades systemd-resolved snapd netplan.io
|
||||
|
||||
rm -rf /etc/netplan/
|
||||
rm -rf /usr/share/netplan/
|
||||
rm -rf ~/snap
|
||||
rm -rf /var/snap
|
||||
rm -rf /var/lib/snapd
|
||||
|
||||
rm -f /etc/network/*.BeforeVMwareCustomization
|
||||
|
||||
sed '/^#/d' -i /etc/resolv.conf
|
||||
|
||||
sed '/^\/root\/first_start.sh &/d' -i /etc/rc.local
|
||||
|
||||
rm /root/first_start.sh
|
||||
|
||||
sleep 5
|
||||
|
||||
echo "Clean all logs"
|
||||
find /var/log -type f,l | xargs rm -f
|
||||
|
||||
reboot
|
@ -10,24 +10,6 @@
|
||||
set_fact: os_group_for_sudo="wheel"
|
||||
when: ansible_os_family == "RedHat"
|
||||
|
||||
- name: Change default for add user create params perm 755 to 700 (Debian)
|
||||
block:
|
||||
- name: Edit options in /etc/adduser.conf
|
||||
lineinfile:
|
||||
path: /etc/adduser.conf
|
||||
line: "{{ item }}"
|
||||
loop:
|
||||
- DIR_MODE=0700
|
||||
- SYS_DIR_MODE=0700
|
||||
when: ansible_os_family == "Debian"
|
||||
- name: Edit options in /etc/login.defs
|
||||
lineinfile:
|
||||
path: /etc/login.defs
|
||||
line: "{{ item }}"
|
||||
loop:
|
||||
- HOME_MODE 0700
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Add admins users
|
||||
user:
|
||||
name: "{{ item.username }}"
|
||||
@ -39,6 +21,14 @@
|
||||
loop: "{{ os_creds_sysadmins }}"
|
||||
no_log: true
|
||||
|
||||
- name: Change perm for home dir 0700
|
||||
file:
|
||||
path: /home/{{ item.username }}
|
||||
state: directory
|
||||
mode: '0700'
|
||||
loop: "{{ os_creds_sysadmins }}"
|
||||
no_log: true
|
||||
|
||||
- name: Add SSH keys for admins users
|
||||
authorized_key:
|
||||
user: "{{ item.username }}"
|
@ -9,6 +9,9 @@
|
||||
- name: IPv6 disable
|
||||
import_tasks: ipv6-disable.yml
|
||||
|
||||
- name: OS basic config
|
||||
import_tasks: os-config.yml
|
||||
|
||||
- name: Add admins users
|
||||
import_tasks: add-users-admins.yml
|
||||
|
50
ansible/roles/os-linux-prep-templ/tasks/os-config.yml
Normal file
50
ansible/roles/os-linux-prep-templ/tasks/os-config.yml
Normal file
@ -0,0 +1,50 @@
|
||||
---
|
||||
|
||||
- name: Change default for add user create params perm 755 to 700 (Debian 12)
|
||||
block:
|
||||
- name: Edit options in /etc/login.defs (Debian 12)
|
||||
lineinfile:
|
||||
regexp: "(^#HOME_MODE)|(^HOME_MODE)"
|
||||
path: /etc/login.defs
|
||||
line: "HOME_MODE 0700"
|
||||
when: (ansible_os_family == "Debian" and ansible_distribution_major_version == "12") or ( ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "24")
|
||||
|
||||
|
||||
- name: Make dir for mc in /etc/skel dir
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0700'
|
||||
loop:
|
||||
- /etc/skel/.config/mc
|
||||
- /root/.config/mc
|
||||
|
||||
- name: Copy default files for skeleton
|
||||
copy:
|
||||
src: "files/{{ item }}"
|
||||
dest: "/etc/skel/{{ item }}"
|
||||
loop:
|
||||
- .bashrc
|
||||
- .config/mc/ini
|
||||
- .config/mc/panels.ini
|
||||
|
||||
- name: Copy default config file for root
|
||||
copy:
|
||||
src: "files/{{ item }}"
|
||||
dest: "/root/{{ item }}"
|
||||
loop:
|
||||
- .bashrc
|
||||
- .config/mc/ini
|
||||
- .config/mc/panels.ini
|
||||
|
||||
- name: Make welcome massage
|
||||
copy:
|
||||
dest: /etc/update-motd.d/99-custom
|
||||
mode: '0755'
|
||||
content: |
|
||||
#!/bin/bash
|
||||
#
|
||||
echo; hostname -f | sed 's/.*/\U&/' | sed 's/^/=> /' | sed 's/$/ <=/' | toilet -f term -F border --gay
|
||||
|
25
ansible/roles/os-linux-prep-templ/tasks/pkg-install.yml
Normal file
25
ansible/roles/os-linux-prep-templ/tasks/pkg-install.yml
Normal file
@ -0,0 +1,25 @@
|
||||
---
|
||||
|
||||
- include_vars: os-pkg-list.yml
|
||||
|
||||
- name: Install of packages for Debian
|
||||
block:
|
||||
- name: Install from list of packages for Debian
|
||||
apt:
|
||||
state: latest
|
||||
pkg: "{{ debian_install_pkg_list }}"
|
||||
- name: Run "apt-get clean" for Debian
|
||||
apt:
|
||||
clean: yes
|
||||
when: ansible_distribution == "Debian"
|
||||
|
||||
- name: Install of packages for Ubuntu
|
||||
block:
|
||||
- name: Install from list of packages for Ubuntu
|
||||
apt:
|
||||
state: latest
|
||||
pkg: "{{ ubuntu_install_pkg_list }}"
|
||||
- name: Run "apt-get clean" for Ubuntu
|
||||
apt:
|
||||
clean: yes
|
||||
when: ansible_distribution == "Ubuntu"
|
@ -0,0 +1,40 @@
|
||||
---
|
||||
|
||||
- name: Prepare scripts for custom VMs (First start)
|
||||
block:
|
||||
- name: Copy files to remote system Debian
|
||||
copy:
|
||||
src: files/first_start_debian.sh
|
||||
dest: /root/first_start.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
- name: Edit /etc/rc.local
|
||||
lineinfile:
|
||||
path: /etc/rc.local
|
||||
regexp: '^(exit 0.*)$'
|
||||
line: |
|
||||
chmod 755 /root/first_start.sh | sed 's/^chmod 755 \/root\/first_start.sh.*/\/root\/first_start.sh \&/' -i /etc/rc.local &
|
||||
exit 0
|
||||
|
||||
when: ansible_distribution == "Debian"
|
||||
|
||||
|
||||
- name: Prepare scripts for custom VMs (First start)
|
||||
block:
|
||||
- name: Copy files to remote system Ubuntu
|
||||
copy:
|
||||
src: files/first_start_ubuntu.sh
|
||||
dest: /root/first_start.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
- name: Edit /etc/rc.local
|
||||
lineinfile:
|
||||
path: /etc/rc.local
|
||||
regexp: '^(exit 0.*)$'
|
||||
line: |
|
||||
chmod 755 /root/first_start.sh | sed 's/^chmod 755 \/root\/first_start.sh.*/\/root\/first_start.sh \&/' -i /etc/rc.local &
|
||||
exit 0
|
||||
|
||||
when: ansible_distribution == "Ubuntu"
|
@ -2,3 +2,4 @@
|
||||
|
||||
os_creds_sysadmins:
|
||||
- { username: "user", password: "*", comment: "mr. User", ssh_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC21HOAhC6o25M1oKxKsZxIoxUUeIpb4oqtAdPRNGU4PhJL1g1Cnro+YeF36YnvTKHRzDxS211y/zZBkt7BxOM7qj6dTQSH23jRwGLyfcYv7VyrK1YoxUAXumOJYnhfjVhXoznKnY9++GO9a/1gxQCzjGFMoxAQxFiBMbR/3Ic92ix2SM5aftXl1Mvu3mv45iZimyVIOH5cXdC0XtDSC7EEsdp1Ex6H/GfYabS+cJ55Uyct3orVBSf1LYFLaBNpIx7evXe+bXl81pvW8k/JhYTizoYNEA9rCi+1zaLQMb5LviHM3QqiYjkJbdt2Bd6TVmAfXrJKkj5XXnaMcDqXg8VUKqBenWOSugwagjYYjPRN/pyOeucL+pW1+iv8rAsVxn/0/eliNMn4rExN+Bj6kOmmdrsfqfierffW4DGDJtZlZhfXeZTX8XhdwMt7QUsUdK/Mr14uaEGjhWywX7uqSTnySV1mG4f6vJOyJksZKNSDzK8zH4k3u3onBFbut6NRG+cW4DaScmDbxAkUyurpesPlQkZzcKit6LLscJWZqCrd09zUvHuktnLuhlcicPQPD0B3VhbqVjTvjTDqZX8ZdxrHaRFwfKtv+gqo5Xb2ziS9MxsslxrSe9Ss4w4XkfbZ3BMnyfJWgxHuuyp4Y9gVRE4pFmsoR3v1zpTTHzMGKJKXWw== user@user" }
|
||||
- { username: "usr2", password: "*", comment: "mr. User", ssh_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC21HOAhC6o25M1oKxKsZxIoxUUeIpb4oqtAdPRNGU4PhJL1g1Cnro+YeF36YnvTKHRzDxS211y/zZBkt7BxOM7qj6dTQSH23jRwGLyfcYv7VyrK1YoxUAXumOJYnhfjVhXoznKnY9++GO9a/1gxQCzjGFMoxAQxFiBMbR/3Ic92ix2SM5aftXl1Mvu3mv45iZimyVIOH5cXdC0XtDSC7EEsdp1Ex6H/GfYabS+cJ55Uyct3orVBSf1LYFLaBNpIx7evXe+bXl81pvW8k/JhYTizoYNEA9rCi+1zaLQMb5LviHM3QqiYjkJbdt2Bd6TVmAfXrJKkj5XXnaMcDqXg8VUKqBenWOSugwagjYYjPRN/pyOeucL+pW1+iv8rAsVxn/0/eliNMn4rExN+Bj6kOmmdrsfqfierffW4DGDJtZlZhfXeZTX8XhdwMt7QUsUdK/Mr14uaEGjhWywX7uqSTnySV1mG4f6vJOyJksZKNSDzK8zH4k3u3onBFbut6NRG+cW4DaScmDbxAkUyurpesPlQkZzcKit6LLscJWZqCrd09zUvHuktnLuhlcicPQPD0B3VhbqVjTvjTDqZX8ZdxrHaRFwfKtv+gqo5Xb2ziS9MxsslxrSe9Ss4w4XkfbZ3BMnyfJWgxHuuyp4Y9gVRE4pFmsoR3v1zpTTHzMGKJKXWw== user@user" }
|
90
ansible/roles/os-linux-prep-templ/vars/os-pkg-list.yml
Normal file
90
ansible/roles/os-linux-prep-templ/vars/os-pkg-list.yml
Normal file
@ -0,0 +1,90 @@
|
||||
---
|
||||
|
||||
debian_install_pkg_list:
|
||||
- net-tools
|
||||
- mc
|
||||
- htop
|
||||
- bash-completion
|
||||
- iotop
|
||||
- iftop
|
||||
- bwm-ng
|
||||
- sysstat
|
||||
- iptraf-ng
|
||||
- iperf3
|
||||
- tcpdump
|
||||
- scsitools
|
||||
- lsscsi
|
||||
- kpartx
|
||||
- toilet
|
||||
- figlet
|
||||
- git
|
||||
- apt-transport-https
|
||||
- sysfsutils
|
||||
- curl
|
||||
- gpg
|
||||
- secure-delete
|
||||
- dnsutils
|
||||
- rpm2cpio
|
||||
- dos2unix
|
||||
- telnet
|
||||
- rsync
|
||||
- sudo
|
||||
- whois
|
||||
- pv
|
||||
- lsof
|
||||
- tmux
|
||||
- hping3
|
||||
- nload
|
||||
- parted
|
||||
- netcat-openbsd
|
||||
- wget
|
||||
- ftp
|
||||
- vim
|
||||
- rsyslog
|
||||
- iptables
|
||||
- man
|
||||
|
||||
ubuntu_install_pkg_list:
|
||||
- net-tools
|
||||
- ifupdown
|
||||
- mc
|
||||
- htop
|
||||
- bash-completion
|
||||
- iotop
|
||||
- iftop
|
||||
- bwm-ng
|
||||
- sysstat
|
||||
- iptraf-ng
|
||||
- iperf3
|
||||
- tcpdump
|
||||
- scsitools
|
||||
- lsscsi
|
||||
- kpartx
|
||||
- toilet
|
||||
- figlet
|
||||
- git
|
||||
- apt-transport-https
|
||||
- sysfsutils
|
||||
- curl
|
||||
- gpg
|
||||
- secure-delete
|
||||
- dnsutils
|
||||
- rpm2cpio
|
||||
- dos2unix
|
||||
- telnet
|
||||
- rsync
|
||||
- sudo
|
||||
- whois
|
||||
- pv
|
||||
- lsof
|
||||
- tmux
|
||||
- hping3
|
||||
- nload
|
||||
- parted
|
||||
- netcat-openbsd
|
||||
- wget
|
||||
- ftp
|
||||
- vim
|
||||
- rsyslog
|
||||
- iptables
|
||||
- man
|
@ -9,5 +9,5 @@ For secrets and cred vars create $HOME/.secret/.packer/vcsrv-creds.pkrvars.hcl<b
|
||||
|
||||
`connection_username = "root"`<br/>
|
||||
`connection_password = "XXXXXXXX"`<br/>
|
||||
`ssh_private_key_file = "/root/.ssh/XXXXXXX_ansible"`<br/>
|
||||
`ssh_private_key_file = "~/.ssh/XXXXXXX_ansible"`<br/>
|
||||
<br/>
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
packer="/usr/bin/packer"
|
||||
|
||||
vm_name="x-debian-packer-vm"
|
||||
vm_name="x-debian12-packer-vm"
|
||||
|
||||
# => For logs:
|
||||
#export PACKER_LOG_PATH=./build-debian-12-amd64.log
|
||||
#export PACKER_LOG_PATH=./build-debian-12-x64.log
|
||||
export PACKER_LOG=0
|
||||
|
||||
creds_vars_file="$HOME/.secret/.packer/vcsrv-creds.pkrvars.hcl"
|
||||
|
5
packer/linux/build-ubuntu-24.04-x64.sh
Normal file → Executable file
5
packer/linux/build-ubuntu-24.04-x64.sh
Normal file → Executable file
@ -2,10 +2,10 @@
|
||||
|
||||
packer="/usr/bin/packer"
|
||||
|
||||
vm_name="x-ubuntu-packer-vm"
|
||||
vm_name="x-ubuntu24-packer-vm"
|
||||
|
||||
# => For logs:
|
||||
#export PACKER_LOG_PATH=./build-debian-12-amd64.log
|
||||
#export PACKER_LOG_PATH=./build-ubuntu-24.04-x64.log
|
||||
export PACKER_LOG=0
|
||||
|
||||
creds_vars_file="$HOME/.secret/.packer/vcsrv-creds.pkrvars.hcl"
|
||||
@ -17,4 +17,3 @@ $packer build -force \
|
||||
-var-file="$HOME/packer/linux/ubuntu-24.04-x64/conf.pkrvars.hcl" \
|
||||
-var vm_name=$vm_name \
|
||||
$HOME/packer/linux/ubuntu-24.04-x64/
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
vcenter_datacenter = "DC01"
|
||||
vcenter_cluster = "Cluster01"
|
||||
vcenter_host = "esxi8-01.lab.loc"
|
||||
vcenter_folder = "VLAN-0221"
|
||||
vcenter_host = "esxi8-02.lab.loc"
|
||||
vcenter_folder = "z-Templates"
|
||||
vcenter_datastore = "Cluster01-LUN02"
|
||||
|
||||
//vm_name = "z-debian-packer-vm"
|
||||
|
@ -27,6 +27,7 @@ sudo echo "#!/bin/sh -e
|
||||
#
|
||||
# By default this script does nothing.
|
||||
|
||||
|
||||
exit 0
|
||||
" > /etc/rc.local
|
||||
|
||||
|
@ -87,7 +87,7 @@ build {
|
||||
|
||||
provisioner "shell-local" {
|
||||
inline = [
|
||||
"ansible-playbook ~/ansible/playbooks/os-linux-prep-default.yml -l packer-templ -e hosts_target=packer-templ -e ansible_host=${build.Host} -e connection_username=${var.connection_username} -e connection_ssh_private_key_file=${var.connection_ssh_private_key_file}"
|
||||
"ansible-playbook ~/ansible/playbooks/os-linux-prep-templ.yml -l packer-templ-debian-12-x64 -e hosts_target=packer-templ-debian-12-x64 -e ansible_host=${build.Host} -e connection_username=${var.connection_username} -e connection_ssh_private_key_file=${var.connection_ssh_private_key_file}"
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -85,12 +85,12 @@ d-i partman/mount_style select uuid
|
||||
# mkpasswd -s -m sha-512
|
||||
#
|
||||
d-i passwd/root-login boolean true
|
||||
d-i passwd/root-password-crypted password $6$Lij5f1fxeWVCjFbJ$GiWa3/zslkXwE4OfHeQrx/AlDPqhZR9pxSMxAvEZX8twF8ti7L6KM8wQWARzH.nQ99/BEmrjfDM/hwuczDJxY1
|
||||
d-i passwd/root-password-crypted password $6$5nLO9zRvoiQP7DdR$DYRibWnOQncB0qR9ugRSqAxWwVCPMfeRUBDdTuYxjh2FSZyRKtf57CG8ybGbFjVCAzJdcQg9qtJYhI.LhWhhe1
|
||||
# Create [ ansb-srv-it ] user account.
|
||||
d-i passwd/make-user boolean true
|
||||
d-i passwd/user-fullname string ansb-srv-it
|
||||
d-i passwd/username string ansb-srv-it
|
||||
d-i passwd/user-password-crypted password $6$Lij5f1fxeWVCjFbJ$GiWa3/zslkXwE4OfHeQrx/AlDPqhZR9pxSMxAvEZX8twF8ti7L6KM8wQWARzH.nQ99/BEmrjfDM/hwuczDJxY1
|
||||
d-i passwd/user-password-crypted password $6$5nLO9zRvoiQP7DdR$DYRibWnOQncB0qR9ugRSqAxWwVCPMfeRUBDdTuYxjh2FSZyRKtf57CG8ybGbFjVCAzJdcQg9qtJYhI.LhWhhe1
|
||||
|
||||
d-i user-setup/allow-password-weak boolean true
|
||||
d-i user-setup/encrypt-home boolean false
|
||||
|
@ -1,7 +1,7 @@
|
||||
vcenter_datacenter = "DC01"
|
||||
vcenter_cluster = "Cluster01"
|
||||
vcenter_host = "esxi8-01.lab.loc"
|
||||
vcenter_folder = "VLAN-0221"
|
||||
vcenter_folder = "z-Templates"
|
||||
vcenter_datastore = "Cluster01-LUN02"
|
||||
|
||||
//vm_name = "z-ubuntu-packer-vm"
|
||||
|
@ -27,6 +27,7 @@ sudo echo "#!/bin/sh -e
|
||||
#
|
||||
# By default this script does nothing.
|
||||
|
||||
|
||||
exit 0
|
||||
" > /etc/rc.local
|
||||
|
||||
|
@ -7,7 +7,7 @@ autoinstall:
|
||||
identity:
|
||||
hostname: ubuntu-24-04-auto-tmpl
|
||||
username: ansb-srv-it
|
||||
password: '$6$R789K/T7lS27KICW$2i5f/sP6nXniEMbjnTyswKMdStGVQdbz8jqIyrXxrhYxJLD0JrWTZjnlFpWkEOlJ2Oa9WvEcANu9iLY3mg5mw.'
|
||||
password: '$6$5nLO9zRvoiQP7DdR$DYRibWnOQncB0qR9ugRSqAxWwVCPMfeRUBDdTuYxjh2FSZyRKtf57CG8ybGbFjVCAzJdcQg9qtJYhI.LhWhhe1'
|
||||
storage:
|
||||
config:
|
||||
- {ptable: gpt, path: /dev/sda, wipe: superblock, preserve: false, name: '', grub_device: true, type: disk, id: disk-sda}
|
||||
@ -36,6 +36,10 @@ autoinstall:
|
||||
updates: all
|
||||
packages:
|
||||
- open-vm-tools
|
||||
- ifupdown
|
||||
- perl-modules-*
|
||||
- net-tools
|
||||
- util-linux-extra
|
||||
- sudo
|
||||
late-commands:
|
||||
- echo 'ansb-srv-it ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/ansb-srv-it
|
||||
|
@ -32,7 +32,7 @@ source "vsphere-iso" "ubuntu-24-04-x64" {
|
||||
host = var.vcenter_host
|
||||
datastore = var.vcenter_datastore
|
||||
folder = var.vcenter_folder
|
||||
# convert_to_template = true
|
||||
convert_to_template = true
|
||||
// ****************
|
||||
vm_name = var.vm_name
|
||||
CPUs = var.vm_num_cpu
|
||||
@ -85,10 +85,10 @@ build {
|
||||
]
|
||||
}
|
||||
|
||||
// provisioner "shell-local" {
|
||||
// inline = [
|
||||
// "ansible-playbook ~/ansible/playbooks/os-linux-prep-default.yml -l packer-templ -e hosts_target=packer-templ -e ansible_host=${build.Host} -e connection_username=${var.connection_username} -e connection_ssh_private_key_file=${var.connection_ssh_private_key_file}"
|
||||
// ]
|
||||
// }
|
||||
provisioner "shell-local" {
|
||||
inline = [
|
||||
"ansible-playbook ~/ansible/playbooks/os-linux-prep-templ.yml -l packer-templ-ubuntu-24-04-x64 -e hosts_target=packer-templ-ubuntu-24-04-x64 -e ansible_host=${build.Host} -e connection_username=${var.connection_username} -e connection_ssh_private_key_file=${var.connection_ssh_private_key_file}"
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user