Skip to content

Commit

Permalink
Implementing rocky linux for vagrant env
Browse files Browse the repository at this point in the history
  • Loading branch information
MariuszJozwiak authored and Szpadel committed Jul 12, 2024
1 parent 92c4a3b commit a60d34e
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 135 deletions.
2 changes: 1 addition & 1 deletion ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fact_caching_connection = tmp/fact_cache
fact_caching_timeout = 2700
fact_caching_prefix = mageops-facts

callback_whitelist = timer, profile_tasks
callback_enabled = timer, profile_tasks

collections_scan_sys_path = False

Expand Down
1 change: 0 additions & 1 deletion group_vars/vagrant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ php_http_request_max_execution_time: 600


mysql_public_root_access: yes
mysql_mariadb_flavor: yes

nginx_app_port: 80

Expand Down
3 changes: 3 additions & 0 deletions inventory/vagrant.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ virtualbox
[dev:children]
vagrant

[app]
virtualbox

[app:children]
vagrant

Expand Down
2 changes: 2 additions & 0 deletions requirements-galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ collections:
version: 2.18.0
- name: ansible.netcommon
version: 5.1.2
- community.crypto
- ansible.posix
4 changes: 2 additions & 2 deletions roles/cs.aws-rds/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ aws_rds_allow_major_version_upgrade: no
aws_rds_storage_size: 20
aws_rds_storage_encrypt: no
aws_rds_dedicated_encryption_key: no
aws_rds_db_engine: mariadb
aws_rds_db_engine: mysql
aws_rds_availability_zone: "{{ aws_preferred_availability_zone }}"
aws_rds_subnet_group_name: "{{ mageops_app_name }}"
aws_rds_subnet_group_subnets: "{{ aws_vpc_subnet_ids }}"
aws_rds_security_groups:
- "{{ aws_security_group_rds_id }}"
aws_rds_param_group_name: "{{ mageops_app_name }}-{{ aws_rds_param_group_engine | replace('.', '-') }}"
aws_rds_param_group_desc: "MageOps parameter group"
aws_rds_db_engine_version: "10.4"
aws_rds_db_engine_version: "8.0"
aws_rds_param_group_engine: "{{ aws_rds_db_engine }}{{ aws_rds_db_engine_version }}"

# https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PerfInsights.Overview.Engines.html
Expand Down
1 change: 0 additions & 1 deletion roles/cs.mysql/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mysql_root_user: root
mysql_root_pass: root
mysql_public_root_access: no
mysql_mariadb_flavor: yes
Empty file removed roles/cs.mysql/handlers/main.yml
Empty file.
4 changes: 1 addition & 3 deletions roles/cs.mysql/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
dependencies:
- role: cs.repo-mariadb
when: mysql_mariadb_flavor

42 changes: 36 additions & 6 deletions roles/cs.mysql/tasks/001-install.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
- name: Setup Mysql
include_tasks: flavor/mysql.yml
when: not mysql_mariadb_flavor
- name: Install mysql-server
dnf:
name: mysql-server
state: present
register: mysql_install

- name: Setup Mariadb
include_tasks: flavor/mariadb.yml
when: mysql_mariadb_flavor
- name: Execute upstream mysql role
import_role:
name: geerlingguy.mysql
vars:
mysql_root_name: "{{ mysql_root_user }}"
mysql_root_password: "{{ mysql_root_pass }}"
mysql_root_password_update: yes
mysql_daemon: mysqld
mysql_packages:
- mysql-server
- mysql
mysql_syslog_tag: mysqld
mysql_pid_file: /run/mysqld/mysqld.pid
mysql_socket: /var/lib/mysql/mysql.sock
mysql_datadir: /var/lib/mysql
mysql_log_error: /var/log/mysql/mysqld.err
mysql_slow_query_log_enabled: yes
mysql_slow_query_time: 1
mysql_log: ""

- name: Add a line to a file if the file does not exist, without passing regexp
ansible.builtin.lineinfile:
path: /etc/my.cnf
insertafter: "pid-file"
firstmatch: true
line: log-bin-trust-function-creators = 1

- name: Restart mysql
ansible.builtin.service:
name: mysqld
state: restarted
56 changes: 0 additions & 56 deletions roles/cs.mysql/tasks/flavor/mariadb.yml

This file was deleted.

37 changes: 0 additions & 37 deletions roles/cs.mysql/tasks/flavor/mysql.yml

This file was deleted.

2 changes: 1 addition & 1 deletion roles/cs.unison/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dependencies:
- role: cs.repo-mageops
when: ansible_distribution | lower == 'centos'
when: ansible_distribution | lower == 'rocky'
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
- name: <CentOS> Increase max inotify watches for unison
- name: <Rocky> Increase max inotify watches for unison
sysctl:
name: fs.inotify.max_user_watches
value: "{{ unison_linux_inotify_max_user_watches | string }}"
reload: yes
state: present

- name: <CentOS> Make sure conflicting packages are absent
- name: <Rocky> Make sure conflicting packages are absent
dnf:
name:
- unison-static
- unison-ocaml406
state: absent

- name: <CentOS> Install latest unison version from MageOps RPM repo
- name: <Rocky> Install latest unison version from MageOps RPM repo
dnf:
name: unison
state: latest
Expand Down
6 changes: 3 additions & 3 deletions roles/cs.unison/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- name: Fail with warning about unspported OS
when: ansible_distribution | lower not in ['macosx', 'centos']
when: ansible_distribution | lower not in ['macosx', 'rocky']
debug:
msg: |
Expand All @@ -18,5 +18,5 @@
when: ansible_distribution | lower == 'macosx'

- name: Install unison client for CentOS
import_tasks: install-centos.yml
when: ansible_distribution | lower == 'centos'
import_tasks: install-rocky.yml
when: ansible_distribution | lower == 'rocky'
5 changes: 4 additions & 1 deletion roles/cs.vagrant/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ cs_vagrant_dir: "{{ playbook_dir }}/../vagrant"
# Virtualbox VM memory
cs_vagrant_vm_memory: 3072

#Virtualbox disk size
cs_vagrant_disk_size: 20GB

# Host CPU Usage cap in percent, if falsey then disabled
cs_vagrant_vm_cpu_cap: no

Expand All @@ -26,7 +29,7 @@ cs_vagrant_vm_cpus: 2

# Please change the name if you upload new box, as we don't have a registry vagrant
# will use locally cached old box version if you change only the URL!
cs_vagrant_vm_box: "centos/7"
cs_vagrant_vm_box: "rockylinux/9"

# URL pointing to the base vagrant box
cs_vagrant_vm_box_url: ~
Expand Down
37 changes: 17 additions & 20 deletions roles/cs.vagrant/templates/Vagrantfile.rb.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Vagrant.configure("2") do |config|
config.vm.box = "{{ cs_vagrant_vm_box }}"
# Do not sync any folders, we use unison directly for custom project sync
config.vm.synced_folder '.', '/vagrant', disabled: true
config.vm.disk :disk, size: "{{ cs_vagrant_disk_size }}", primary: true

{% if cs_vagrant_vm_box_url %}
config.vm.box_url = "{{ cs_vagrant_vm_box_url }}"
Expand All @@ -38,27 +39,23 @@ Vagrant.configure("2") do |config|
# TODO: Find a better method for getting adapter names
config.vm.network "public_network"
{% endif -%}
#Extending partition according to disk size
config.vm.provision "shell", inline: <<-SHELL
printf "\nDisk free space before...\n"
df -lhT /
{% if cs_vagrant_vm_box == 'mageops/centos' %}
vb.customize [
"storageattach", :id,
"--storagectl", "SATA",
"--device", "0",
"--port", "2",
"--type", "dvddrive",
"--medium", "additions"
]
{% else %}
{% if cs_vagrant_vm_enable_cd %}
# Empty CD drive for optional Guest Additions Installation
vb.customize ["storageattach", :id,
"--storagectl", "IDE Controller",
"--port", "0", "--device", "1",
"--type", "dvddrive",
"--medium", "emptydrive"]
{% endif %}
{% endif %}
end
printf "\nResizing / partition live with sgdisk...\n"
dnf install -y gdisk
sgdisk -g -e /dev/sda
sgdisk -d 5 /dev/sda
sgdisk -N 5 /dev/sda
partprobe /dev/sda
xfs_growfs /dev/sda5
printf "\nDisk free space after...\n"
df -lhT /
SHELL
end


config.vm.post_up_message = <<EOF_UP_MSG
Expand Down
2 changes: 2 additions & 0 deletions vagrant.configure-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
include_role:
name: cs.magento-configure
tasks_from: vagrant.yml
vars:
mageops_mysql_host: 192.168.57.100

# Normally deploy does it, but we don't deploy to vagrant
- name: Add nginx to magento group
Expand Down

0 comments on commit a60d34e

Please sign in to comment.