Skip to content

Commit

Permalink
Upadte provisioner with fixes
Browse files Browse the repository at this point in the history
(reference #118)
  • Loading branch information
piotrzarzycki21 committed Jan 15, 2025
1 parent 9b44ad4 commit e6e6a18
Show file tree
Hide file tree
Showing 7 changed files with 268 additions and 192 deletions.
48 changes: 42 additions & 6 deletions Assets/provisioners/demo-tasks/0.1.23/scripts/core/Hosts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -628,23 +628,59 @@ def self.rsync_version_low?
end

def self.configure_plugins(host)
return unless ARGV[0] == 'up' # Only configure plugins during 'vagrant up'

plugins = host['plugins'] || {}
install_plugins = Array(plugins['install'])
remove_plugins = Array(plugins['remove'])
needs_reload = false

# Track plugin update states
@@plugin_states ||= {}

# Remove plugins
remove_plugins.each do |plugin|
if Vagrant.has_plugin?(plugin['name'])
system("vagrant plugin uninstall #{plugin['name']}")
needs_reload = true
end
end

# Install plugins
# Install and update plugins
install_plugins.each do |plugin|
next if Vagrant.has_plugin?(plugin['name'])

version_option = plugin['version'] == 'latest' ? '' : "--plugin-version #{plugin['version']}"
system("vagrant plugin install #{plugin['name']} #{version_option}")
if Vagrant.has_plugin?(plugin['name'])
# Only update plugins marked as 'latest'
if plugin['version'] == 'latest'
puts "Checking for updates to #{plugin['name']}..."
output = %x(vagrant plugin update #{plugin['name']})
if output.include?("Updated '#{plugin['name']}'")
needs_reload = true
end
elsif plugin['version'] != 'latest'
# For specific version, check if version matches
current_version = %x(vagrant plugin list | grep #{plugin['name']}).split('(').last.split(')').first.strip
if current_version != plugin['version']
system("vagrant plugin uninstall #{plugin['name']}")
system("vagrant plugin install #{plugin['name']} --plugin-version #{plugin['version']}")
needs_reload = true
end
end
else
# Install missing plugin
if plugin['version'] == 'latest'
system("vagrant plugin install #{plugin['name']}")
else
system("vagrant plugin install #{plugin['name']} --plugin-version #{plugin['version']}")
end
needs_reload = true
end
end

# If any plugins were updated/installed/removed, reload Vagrant
if needs_reload
puts "Plugin changes detected - reloading Vagrant environment"
system("vagrant plugin clean")
exec("vagrant", *ARGV)
end
end

Expand All @@ -669,4 +705,4 @@ def self.write_results_file(data, file_path, yaml)
end
end

end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,45 @@

-
name: "Updating yum cache"
become: yes
ansible.builtin.yum:
update_cache: true

-
name: "Upgrading all yum packages"
become: yes
ansible.builtin.yum:
name: '*'
state: latest # noqa package-latest

-
name: "Installing EPEL repo"
become: yes
ansible.builtin.yum:
name: epel-release
state: present

-
name: "Ensuring EPEL repo is enabled"
become: yes
ansible.builtin.ini_file:
path: /etc/yum.repos.d/epel.repo
section: epel
option: enabled
value: '1'

-
name: "Installing utilities to enable package repositories"
become: yes
ansible.builtin.package:
name: yum-utils
state: latest

-
name: "Updating yum cache"
ansible.builtin.yum:
update_cache: true

-
name: "Installing packages"
ansible.builtin.yum:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ packages:
- cloud-init
- dkms
- uuid
- authbind
# - authbind
# - lynx
# - systemd-resolved
- nano
- vim
- rsync
Expand Down Expand Up @@ -62,14 +64,12 @@ packages:
- zlib-devel
- glibc.i686
- libstdc++
- lynx
- lshw
- memtest86+
- htop
- iotop
- iftop
- psmisc
- systemd-resolved
- tree
- jq
- bc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
-
name: "Extending the unecrypted Root Partition"
ansible.builtin.shell: "{{ item }}"
ignore_errors: true
register: extend_root_partition
failed_when:
- extend_root_partition.rc != 0
- "'NOCHANGE' not in extend_root_partition.stdout"
- "'Bad magic number' not in extend_root_partition.stderr"
changed_when: extend_root_partition.rc == 0
with_items:
- "growpart /dev/{{ root_disk }} {{ root_partition_number }}"
- "resize2fs /dev/{{ root_partition }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,39 @@
state: started # Ensures the service is running.
enabled: true # Enables the service to start on boot.

-
name: "Checking if Python HTTP server is listening on port {{ startcloud_quick_start_port_forwards[0].guest }}" # Checks if Python HTTP server is listening
when: not ansible_module_running_in_container
ansible.builtin.wait_for:
port: "{{ startcloud_quick_start_port_forwards[0].guest }}" # Specifies the port to check.
delay: 5 # Waits for 5 seconds before checking.
timeout: 60 # Sets a 60-second timeout for the check.
msg: "Timeout waiting for {{ startcloud_quick_start_port_forwards[0].guest }} to respond" # Custom message displayed if the check times out.
register: port_check # Stores the result for later use.
ignore_errors: true # Ignores errors if the port check fails.

-
name: "Restarting Cockpit" # Restarts the Cockpit service.
when: not ansible_module_running_in_container
ansible.builtin.systemd:
state: restarted # Restarts the service.
daemon_reload: true # Reloads the systemd manager configuration.
name: cockpit # Specifies the service name.

-
name: "Copying pythonserver supervisord configuration file"
when: ansible_module_running_in_container
ansible.builtin.template:
src: supervisord.pythonserver.conf.j2
dest: /etc/supervisor/conf.d/supervisord.pythonserver.conf
owner: root
group: root
mode: '0644'

-
name: "Block to always run these tasks"
when: true
block:
-
name: "Zipping Ansible Playbook Into Support Bundle" # Archives the Ansible roles directory into a ZIP file for support purposes.
community.general.archive:
Expand All @@ -186,10 +219,17 @@
force: false # Does not overwrite existing files.
mode: 'a+x' # Appends to the file and sets execute permission.

-
name: "Checking if Domino has been autoconfigured"
register: autoconfigure
ansible.builtin.stat:
path: "{{ domino_home_dir }}/IBM_TECHNICAL_SUPPORT/autoconfigure.log"
get_md5: false

-
name: "Including Domino One Touch autoconfigure to /vagrant/support-bundle/autoconfigure.log" # Copies the Domino One Touch log to the support bundle.
become: true # Executes the task with elevated privileges.
when: domino_home_dir is defined # Only runs if the domino_home_dir variable is defined.
when: domino_home_dir is defined and autoconfigure.stat.exists # Only runs if the domino_home_dir variable is defined.
ansible.builtin.copy:
src: "{{ domino_home_dir }}/IBM_TECHNICAL_SUPPORT/autoconfigure.log" # Specifies the source file.
dest: "/vagrant/support-bundle/autoconfigure.log" # Specifies the destination file.
Expand All @@ -210,18 +250,7 @@
dest: "/vagrant/support-bundle/completed.json" # Specifies the destination file.
force: false # Does not overwrite existing files.
mode: 'a+x' # Appends to the file and sets execute permission.

-
name: "Checking if Python HTTP server is listening on port {{ startcloud_quick_start_port_forwards[0].guest }}" # Checks if Python HTTP server is listening
when: not ansible_module_running_in_container
ansible.builtin.wait_for:
port: "{{ startcloud_quick_start_port_forwards[0].guest }}" # Specifies the port to check.
delay: 5 # Waits for 5 seconds before checking.
timeout: 60 # Sets a 60-second timeout for the check.
msg: "Timeout waiting for {{ startcloud_quick_start_port_forwards[0].guest }} to respond" # Custom message displayed if the check times out.
register: port_check # Stores the result for later use.
ignore_errors: true # Ignores errors if the port check fails.


-
name: "Zip Support Bundle" # Archives the support bundle directory into a ZIP file.
community.general.archive:
Expand All @@ -237,21 +266,3 @@
path: "/vagrant/support-bundle"
dest: "/vagrant/support-bundle.zip"
format: zip

-
name: "Restarting Cockpit" # Restarts the Cockpit service.
when: not ansible_module_running_in_container
ansible.builtin.systemd:
state: restarted # Restarts the service.
daemon_reload: true # Reloads the systemd manager configuration.
name: cockpit # Specifies the service name.

-
name: "Copying pythonserver supervisord configuration file"
when: ansible_module_running_in_container
ansible.builtin.template:
src: supervisord.pythonserver.conf.j2
dest: /etc/supervisor/conf.d/supervisord.pythonserver.conf
owner: root
group: root
mode: '0644'
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
line: "{{ item.line }}"
with_items:
- { regexp: '^GRUB_CMDLINE_LINUX_DEFAULT=', line: 'GRUB_CMDLINE_LINUX_DEFAULT="quiet"' }
- { regexp: '^GRUB_CMDLINE_LINUX=', line: 'GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"' }
- { regexp: '^GRUB_CMDLINE_LINUX=', line: 'GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0"' }

-
name: "Updating Grub packages"
Expand Down
Loading

0 comments on commit e6e6a18

Please sign in to comment.