Packer.Images/ansible/roles/os/tasks/packages.yml

69 lines
1.6 KiB
YAML

- name: Configure 'needrestart' package
ansible.builtin.lineinfile:
path: /etc/needrestart/needrestart.conf
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
loop:
- regexp: "^#\\$nrconf\\{restart\\} = 'i';"
line: "$nrconf{restart} = 'a';"
- regexp: "^#\\$nrconf\\{kernelhints\\} = -1;"
line: "$nrconf{kernelhints} = -1;"
loop_control:
label: "{{ item.line }}"
- name: Install additional packages
ansible.builtin.apt:
pkg: "{{ packages.apt }}"
state: latest
update_cache: yes
install_recommends: no
- name: Upgrade all packages
ansible.builtin.apt:
name: '*'
state: latest
update_cache: yes
- name: Install additional python packages
ansible.builtin.pip:
name: "{{ item }}"
executable: pip3
state: latest
loop: "{{ packages.pip }}"
- name: Create folder
ansible.builtin.file:
path: /etc/ansible
state: directory
- name: Configure Ansible defaults
ansible.builtin.copy:
dest: /etc/ansible/ansible.cfg
content: |
[defaults]
callbacks_enabled = ansible.posix.profile_tasks
force_color = true
stdout_callback = community.general.diy
[callback_diy]
[callback_profile_tasks]
task_output_limit = 0
- name: Create default shell aliases
ansible.builtin.lineinfile:
path: ~/.bashrc
state: present
line: "{{ item }}"
insertafter: EOF
loop:
- alias k="kubectl"
- alias less="less -rf"
loop_control:
label: "{{ (item | regex_findall('([^ =\"]+)'))[2] }}"
- name: Cleanup
ansible.builtin.apt:
autoremove: yes
purge: yes