Skip to content

Commit

Permalink
Add Azure 1001 user
Browse files Browse the repository at this point in the history
  • Loading branch information
eifelmicha committed Jan 17, 2025
1 parent d4fcebc commit ea77a6c
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 8 deletions.
1 change: 1 addition & 0 deletions azure/.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ PACKER_ANSIBLE_VERSION=1.1.1
PACKER_AMAZON_VERSION=1.3.2
TERRAFORM_VERSION=1.10.3
TFLINT_VERSION=0.36.0
YQ_VERSION=4.44.3
51 changes: 51 additions & 0 deletions azure/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 42 additions & 8 deletions azure/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ ARG ANSIBLE_VERSION \
PACKER_ANSIBLE_VERSION \
PACKER_AMAZON_VERSION \
TERRAFORM_VERSION \
TFLINT_VERSION

COPY ./ansible_collections.yml /ansible_collections.yml
TFLINT_VERSION \
YQ_VERSION

RUN groupadd -g 1001 admin && useradd -u 1001 -g 1001 -s /bin/bash -d /home/admin admin
COPY ansible_collections.yml /home/admin/ansible_collections.yml
COPY provider.tf /home/admin/provider.tf

# Install dependencies.
RUN apt-get update \
Expand All @@ -24,6 +26,7 @@ RUN apt-get update \
ca-certificates \
curl \
git \
less \
locales \
lsb-release \
make \
Expand Down Expand Up @@ -57,21 +60,52 @@ RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12
# Create venv and install tools
RUN python3.12 -m venv /opt/ansible_virtualenv \
&& . /opt/ansible_virtualenv/bin/activate \
&& pip3 install --no-cache-dir --no-compile ansible-core==${ANSIBLE_VERSION} ansible-lint==${ANSIBLE_LINT_VERSION} \
&& ansible-galaxy collection install -r /ansible_collections.yml
&& pip3 install --no-cache-dir --no-compile ansible-core==${ANSIBLE_VERSION} ansible-lint==${ANSIBLE_LINT_VERSION} yamllint \
&& ln -s /opt/ansible_virtualenv/bin/ansible* /usr/bin/ \
&& ln -s /opt/ansible_virtualenv/bin/yamllint /usr/bin/

# Install Packer + Plugins
RUN curl -sLSfo packer.zip https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_$(dpkg --print-architecture).zip && unzip -o packer.zip && mv packer /usr/bin -f && rm packer.zip
RUN packer plugins install "github.com/hashicorp/amazon" ${PACKER_ANSIBLE_VERSION} && \
packer plugins install "github.com/hashicorp/ansible" ${PACKER_ANSIBLE_VERSION}

# Install Terraform
RUN curl -sLSfo terraform.zip https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_$(dpkg --print-architecture).zip && unzip -o terraform.zip && mv terraform /usr/bin -f && rm terraform.zip

# Install TFlint
RUN curl -sLSfo tflint.zip https://github.com/terraform-linters/tflint/releases/download/v${TFLINT_VERSION}/tflint_linux_$(dpkg --print-architecture).zip && unzip -o tflint.zip && mv tflint /usr/bin -f && rm tflint.zip

# Install YQ
RUN curl -sLSfo /usr/bin/yq https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_$(dpkg --print-architecture) && chmod +x /usr/bin/yq

# Install Node.js
RUN curl -sL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs

# sudo for all
RUN usermod -aG sudo admin
RUN echo 'ALL ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# cleanup apt mess
RUN apt-get purge -y man-db && apt-get clean \
&& rm -rf \
/var/lib/apt/lists/* \
/tmp/* \
/var/tmp/* \
/usr/share/doc/* \
/usr/share/man/* \
/usr/share/locale/*

# fatal: detected dubious ownership in repository at '/git'
RUN git config --global --add safe.directory /git

CMD ["/bin/bash"]
RUN chown -R 1001:1001 /home/admin
USER admin
WORKDIR /home/admin

RUN ansible-galaxy collection install -r ~/ansible_collections.yml
RUN packer plugins install "github.com/hashicorp/amazon" ${PACKER_AMAZON_VERSION} && \
packer plugins install "github.com/hashicorp/ansible" ${PACKER_ANSIBLE_VERSION}
RUN terraform init

# No ENTRYPOINT
ENTRYPOINT []
CMD []
18 changes: 18 additions & 0 deletions azure/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.83.1"
}
archive = {
source = "hashicorp/archive"
version = "2.3.0"
}
}
}

provider "aws" {
}

provider "archive" {
}

0 comments on commit ea77a6c

Please sign in to comment.