Github pages blog
List hosts
This is if you run into an issue parsing your hosts file see here:
$ ansible all --list-hosts
Run Ansible playbook against single host:
debops install-tool.yml -i "machine.com," -u timo
Run Ansible play book against localhost:
Ansible ssh Error Local host connection
Add SSH Key to all hosts:
ansible -i ./container-inventory all -m copy -a 'src=./files/customer.pub dest=/home/support/.ssh/authorized_keys mode=0600 owner=support group=support' -e ansible_become=yes -e ansible_ssh_user=timo
Ping users in group:
(Ping users in web group in ansible inventory)
ansible web -m ping
This will install a package based on the architecture:
- name: install mysql-client
apt:
name: mysql-community-client
state: latest
become: yes
when: ansible_architecture == "x86_64"
# Since mysql-client isn't available here just install mariadb-client instead
- name: install Mariadb-client
apt:
name: mariadb-client
state: latest
become: yes
when: ansible_architecture == "aarch64"
This example does source ~/.sdkman/bin/sdkman-init.sh:
- name: Installing gradle with sdkman
shell: "source /home/admin/.sdkman/bin/sdkman-init.sh && sdk install gradle "
args:
executable: /bin/bash
Something like this:
- src: git@github.com:timogoosen/ansible-role.git
name: base
scm: git
version: CPE-1475
Can then test installing it like this(Locally, not on remote host):
ansible-galaxy install -r requirements.yml