Skip to content

Instantly share code, notes, and snippets.

@jpcaparas
Created October 22, 2023 22:52
Show Gist options
  • Save jpcaparas/dbd1d02cec466e8f757ec2ea30b2604f to your computer and use it in GitHub Desktop.
Save jpcaparas/dbd1d02cec466e8f757ec2ea30b2604f to your computer and use it in GitHub Desktop.
Ansible workstation (AMD64 & ARM64)
---
- name: Install multiple packages on localhost for arm64 and amd64 architectures
hosts: localhost
gather_facts: true
connection: local
become: true
become_method: sudo
tasks:
- name: Update package list
apt:
update_cache: yes
- name: Install general packages
apt:
name: "{{ item }}"
state: present
loop:
- vim
- htop
- nginx
when: ansible_architecture in ["aarch64", "amd64"]
- name: Add PHP repository
apt_repository:
repo: ppa:ondrej/php
when: ansible_architecture in ["aarch64", "amd64"]
- name: Try to install PHP 8.2
block:
- name: Install PHP 8.2 packages
apt:
name: "{{ item }}"
state: present
loop:
- php8.2
- php8.2-cli
- php8.2-fpm
- php8.2-json
- php8.2-common
- php8.2-mysql
- php8.2-zip
- php8.2-gd
- php8.2-mbstring
- php8.2-curl
- php8.2-xml
- php8.2-bcmath
rescue:
- name: Handle failure
debug:
msg: "An error occurred during PHP 8.2 package installation. Proceeding to next task."
when: ansible_architecture in ["aarch64", "amd64"]
- name: Install MySQL 8.0
apt:
name: mysql-server
state: present
when: ansible_architecture in ["aarch64", "amd64"]
- name: Install PHPMyAdmin
apt:
name: phpmyadmin
state: present
when: ansible_architecture in ["aarch64", "amd64"]
- name: Download NVM install script
get_url:
url: "https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh"
dest: "/tmp/nvm_install.sh"
mode: "0755"
when: ansible_architecture in ["aarch64", "amd64"]
- name: Install NVM (Node Version Manager)
command:
cmd: "/bin/bash /tmp/nvm_install.sh"
creates: "$HOME/.nvm/nvm.sh"
when: ansible_architecture in ["aarch64", "amd64"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment