Skip to content

Commit

Permalink
feat(254): use local ansible execution
Browse files Browse the repository at this point in the history
Resolves #254.
  • Loading branch information
smoyer64 committed Sep 12, 2022
1 parent 3d41f21 commit c43b96f
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 20 deletions.
17 changes: 0 additions & 17 deletions ansible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,3 @@ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6125E2A8C77F2818FB
sudo apt-add-repository --yes 'deb http://ppa.launchpad.net/ansible/ansible/ubuntu focal main'
sudo apt-get update
sudo apt-get -y install git ansible

# Install and start the SSH server
sudo apt-get -y install openssh-client
sudo apt-get -y install openssh-server
sudo service ssh start

if [ ! -d ~/.ssh ] ; then
mkdir ~/.ssh
fi

if [ ! -f ~/.ssh/ansible-key ] ; then
ssh-keygen -t ed25519 -f ~/.ssh/ansible-key
fi

ssh-keyscan -H 127.0.0.1 >> ~/.ssh/known_hosts
ssh-keyscan -H localhost >> ~/.ssh/known_hosts

6 changes: 6 additions & 0 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

export ANSIBLE_NOCOWS=1
ansible-playbook -K -i localhost, clean.yml $*

rm -f ansible_inventory.ini
26 changes: 26 additions & 0 deletions clean.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
#

- hosts: localhost
connection: local
pre_tasks:
- name: Fail if Ansible version is too old
fail:
msg: "Workstation requires a minimum Ansible version of {{ ansible_minimum_version }}. Please update Ansible and run workstation.sh again."
when: ansible_version.full is version(ansible_minimum_version, operator='lt', strict=True)
- name: abort execution on 32-bit environments
fail:
msg: "These playbooks are now only available on 64-bit OSes"
when: ansible_architecture == "i386"
remote_user: ansible
become: yes
vars_files:
- versions.yml
roles: # The Alpine roles must remain first in the role list
- role: "alpine/common"
tags:
- "alpine"
- role: "alpine/xfce"
tags:
- "alpine"
- clean
17 changes: 17 additions & 0 deletions roles/clean/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
#

- name: remove the ansible user's privileges (sudo)
file:
path: /etc/sudoers.d/ansible
state: absent
tags:
- clean-legacy

- name: remove the ansible user's account
user:
name: ansible
state: absent
remove: yes
tags:
- clean-legacy
2 changes: 1 addition & 1 deletion workstation.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh

export ANSIBLE_NOCOWS=1
ansible-playbook --private-key=~/.ssh/ansible-key -i ansible_inventory.ini workstation.yml $*
ansible-playbook -K -i localhost, workstation.yml $*
5 changes: 3 additions & 2 deletions workstation.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
# File: workstation.yml

- hosts: all
- hosts: localhost
connection: local
pre_tasks:
- name: Fail if Ansible version is too old
fail:
Expand Down Expand Up @@ -49,7 +50,7 @@
- visual_studio
- security

- hosts: 127.0.0.1
- hosts: localhost
connection: local
pre_tasks:
- name: Fail if Ansible version is too old
Expand Down

0 comments on commit c43b96f

Please sign in to comment.