Skip to content

Commit

Permalink
fix broken testing
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhonas committed Jul 12, 2024
1 parent 98eb9d8 commit 986b786
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 158 deletions.
2 changes: 1 addition & 1 deletion .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ skip_list:
- command-instead-of-shell # Use shell only when shell functionality is required
- experimental # all rules tagged as experimental
- no-changed-when # Commands should not change things if nothing needs doing

- name[casing]
218 changes: 109 additions & 109 deletions Pipfile.lock

Large diffs are not rendered by default.

82 changes: 41 additions & 41 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,68 +9,68 @@ ANSIBLE_REPO="https://github.com/yuhonas/dotfiles.git"
export ANSIBLE_NOCOWS=1

if [ "$(uname)" == "Darwin" ]; then
# Download and install Command Line Tools
if [[ ! -x /usr/bin/gcc ]]; then
echo "Info | Install | xcode"
xcode-select --install
fi
# Download and install Command Line Tools
if [[ ! -x /usr/bin/gcc ]]; then
echo "Info | Install | xcode"
xcode-select --install
fi

# Download and install homebrew
if [[ ! -x /opt/homebrew/bin/brew ]]; then
echo "Info | Install | homebrew"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
eval $(/opt/homebrew/bin/brew shellenv)
# Download and install homebrew
if [[ ! -x /opt/homebrew/bin/brew ]]; then
echo "Info | Install | homebrew"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
eval $(/opt/homebrew/bin/brew shellenv)
else
# Download and install linuxbrew
if [[ ! -x /home/linuxbrew/.linuxbrew/bin/brew ]]; then
# archlinux
sudo pacman --sync --refresh --noconfirm --needed \
base-devel \
git ca-certificates \
curl \
git \
libxcrypt-compat # for homebrew installation which installs ruby 2.6.8
# Download and install linuxbrew
if [[ ! -x /home/linuxbrew/.linuxbrew/bin/brew ]]; then
# archlinux
sudo pacman --sync --refresh --noconfirm --needed \
base-devel \
git ca-certificates \
curl \
git \
libxcrypt-compat # for homebrew installation which installs ruby 2.6.8

# set locale
sudo localedef -i en_US -f UTF-8 en_US.UTF-8
# set locale
sudo localedef -i en_US -f UTF-8 en_US.UTF-8

echo "Info | Install | linuxbrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)' >>$HOME/.bash_profile
fi
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
echo "Info | Install | linuxbrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)' >>$HOME/.bash_profile
fi
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
fi

brew update

# Download and install git
if ! type git > /dev/null 2>&1; then
echo "Info | Install | git"
brew install git
if ! type git >/dev/null 2>&1; then
echo "Info | Install | git"
brew install git
fi

# Download and install Ansible
if ! type ansible > /dev/null 2>&1; then
echo "Info | Install | ansible"
brew install ansible
if ! type ansible >/dev/null 2>&1; then
echo "Info | Install | ansible"
brew install ansible
fi

# Make the code directory
mkdir -p $SRC_DIRECTORY

# Clone down ansible
if [[ ! -d $ANSIBLE_DIRECTORY ]]; then
git clone $ANSIBLE_REPO $ANSIBLE_DIRECTORY
git clone $ANSIBLE_REPO $ANSIBLE_DIRECTORY

# if we're part of a build we should checkout the supplied SHA
if [[ -n "$GITHUB_SHA" ]]; then
git checkout "$GITHUB_SHA"
fi
# if we're part of a build we should checkout the supplied SHA
if [[ -n "$GITHUB_SHA" ]]; then
git checkout "$GITHUB_SHA"
fi
fi

if [[ -z "$NO_PROVISION" ]]; then
# Provision the box
ansible-playbook --ask-become-pass --become-method=sudo -i $ANSIBLE_DIRECTORY/inventory $ANSIBLE_DIRECTORY/playbook.yml
# Provision the box
ansible-playbook --ask-become-pass --become-method=sudo -i $ANSIBLE_DIRECTORY/inventory $ANSIBLE_DIRECTORY/playbook.yml
fi

3 changes: 3 additions & 0 deletions molecule/default/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ RUN set -xe \
&& sed -i "/^%${SUDO_GROUP}/s/ALL\$/NOPASSWD:ALL/g" /etc/sudoers \
&& sed -i "/%wheel/s/^# //g" /etc/sudoers

# set ansible user password to ansible
RUN echo "${ANSIBLE_USER}:${ANSIBLE_USER}" | chpasswd

USER ${ANSIBLE_USER}:${ANSIBLE_USER}
WORKDIR /home/${ANSIBLE_USER}

Expand Down
29 changes: 29 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
- name: Fail if molecule group is missing
hosts: localhost
tasks:
- name: Print some info
ansible.builtin.debug:
msg: "{{ groups }}"

- name: Assert group existence
ansible.builtin.assert:
that: "'molecule' in groups"
fail_msg: |
molecule group was not found inside inventory groups: {{ groups }}
- name: Converge
hosts: molecule
# We disable gather facts because it would fail due to our container not
# having python installed. This will not prevent use from running 'raw'
# commands. Most molecule users are expected to use containers that already
# have python installed in order to avoid notable delays installing it.
gather_facts: false
tasks:
- name: Check uname
ansible.builtin.raw: uname -a
register: result
changed_when: false

- name: Print some info
ansible.builtin.assert:
that: result.stdout | regex_search("^Linux")
22 changes: 15 additions & 7 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
---
driver:
name: "docker"
lint: |
set -e
# yamllint .
ansible-lint -x formatting playbook.yml roles/
flake8
name: docker
dependency:
name: galaxy
options:
requirements-file: requirements.yml
# lint: |
# set -e
# # yamllint .
# ansible-lint -x formatting playbook.yml roles/
# flake8
platforms:
- name: "molecule_instance"
- name: molecule_instance
image: "archlinux/archlinux:latest"
platform: amd64
pre_build_image: false
env:
PATH: "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:$PATH"
ANSIBLE_USER: "linuxbrew"
SUDO_GROUP: "wheel"
DEPLOY_GROUP: "deployer"
scenario:
name: default
provisioner:
name: "ansible"
env:
Expand Down
3 changes: 3 additions & 0 deletions molecule/default/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
collections:
- name: community.docker
version: ">=3.10.2"

0 comments on commit 986b786

Please sign in to comment.