adding tests
- stat doesn't work on remote, need to figure out a workaround
This commit is contained in:
@@ -28,6 +28,4 @@ galaxy_info:
|
|||||||
- package
|
- package
|
||||||
- software
|
- software
|
||||||
|
|
||||||
dependencies:
|
dependencies: []
|
||||||
- ansible.builtin
|
|
||||||
- community.general
|
|
||||||
|
|||||||
@@ -5,21 +5,27 @@
|
|||||||
path: "{{ role_path }}/tasks/pkgs/{{ pkg }}.yml"
|
path: "{{ role_path }}/tasks/pkgs/{{ pkg }}.yml"
|
||||||
register: stat_pkg
|
register: stat_pkg
|
||||||
|
|
||||||
|
- name: Dump stat_pkg
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: stat_pkg
|
||||||
|
|
||||||
- name: "Check if specialized configuration exists for {{ pkg }}"
|
- name: "Check if specialized configuration exists for {{ pkg }}"
|
||||||
when:
|
|
||||||
- stat_pkg.exists
|
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ role_path }}/tasks/config/{{ pkg }}.yml"
|
path: "{{ role_path }}/tasks/config/{{ pkg }}.yml"
|
||||||
register: stat_config
|
register: stat_config
|
||||||
|
|
||||||
|
- name: Dump stat_config
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: stat_config
|
||||||
|
|
||||||
- name: "Load specialized configuration if it exists for {{ pkg }}"
|
- name: "Load specialized configuration if it exists for {{ pkg }}"
|
||||||
when:
|
when:
|
||||||
- stat_config.exists
|
- stat_config.stat.exists
|
||||||
ansible.builtin.include_tasks:
|
ansible.builtin.include_tasks:
|
||||||
file: "config/{{ pkg }}.yml"
|
file: "config/{{ pkg }}.yml"
|
||||||
|
|
||||||
- name: "Add include task for {{ pkg }}"
|
- name: "Add include task for {{ pkg }}"
|
||||||
when:
|
when:
|
||||||
- stat_pkg.exists
|
- stat_pkg.stat.exists
|
||||||
ansible.builtin.include_tasks:
|
ansible.builtin.include_tasks:
|
||||||
file: "pkgs/{{ pkg }}.yml"
|
file: "pkgs/{{ pkg }}.yml"
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
---
|
---
|
||||||
- name: Install go packages
|
- name: Install go packages
|
||||||
become: "{{ archive_become }}"
|
become: "{{ archive_become }}"
|
||||||
|
environment:
|
||||||
|
GOBIN: "{{ paths.bin }}"
|
||||||
|
PATH: "{{ paths.go }}/bin:$PATH"
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
creates: "{{ paths.bin }}/{{ pkg.bin }}"
|
creates: "{{ paths.bin }}/{{ pkg.bin }}"
|
||||||
cmd:
|
cmd:
|
||||||
|
|||||||
@@ -28,8 +28,6 @@
|
|||||||
ansible.builtin.include_tasks:
|
ansible.builtin.include_tasks:
|
||||||
file: addpkg.yml
|
file: addpkg.yml
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- name: Install sys_pkgs list using system package manager
|
- name: Install sys_pkgs list using system package manager
|
||||||
become: "{{ sys_pkg_become }}"
|
become: "{{ sys_pkg_become }}"
|
||||||
ansible.builtin.package:
|
ansible.builtin.package:
|
||||||
@@ -79,9 +77,6 @@
|
|||||||
loop: "{{ go_pkgs | unique }}"
|
loop: "{{ go_pkgs | unique }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: pkg
|
loop_var: pkg
|
||||||
environment:
|
|
||||||
GOBIN: "{{ paths.bin }}"
|
|
||||||
PATH: "{{ paths.go }}/bin:$PATH"
|
|
||||||
ansible.builtin.include_tasks:
|
ansible.builtin.include_tasks:
|
||||||
file: go.yml
|
file: go.yml
|
||||||
|
|
||||||
|
|||||||
17
tests/Containerfile
Normal file
17
tests/Containerfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
FROM fedora:41
|
||||||
|
LABEL PROJECT "ansible_role_package"
|
||||||
|
LABEL MAINTAINER "Matthew Stobbs <matthew@stobbs.ca>"
|
||||||
|
|
||||||
|
RUN useradd -d /home/ansible -m -G wheel ansible
|
||||||
|
RUN dnf install -y openssh-server python3-paramiko python3-libdnf5
|
||||||
|
EXPOSE 22
|
||||||
|
|
||||||
|
USER ansible
|
||||||
|
WORKDIR /home/ansible
|
||||||
|
RUN mkdir /home/ansible/.ssh
|
||||||
|
COPY ./pubkey /home/ansible/.ssh/authorized_keys
|
||||||
|
|
||||||
|
USER root
|
||||||
|
RUN echo "ansible ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/sudoers
|
||||||
|
RUN ssh-keygen -A
|
||||||
|
ENTRYPOINT /usr/sbin/sshd -D
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
localhost
|
|
||||||
|
|
||||||
7
tests/inventory.yml
Normal file
7
tests/inventory.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
test:
|
||||||
|
hosts:
|
||||||
|
localhost:
|
||||||
|
ansible_ssh_host: 127.0.0.1
|
||||||
|
ansible_ssh_port: 2222
|
||||||
|
ansible_ssh_user: ansible
|
||||||
|
ansible_ssh_extra_args: "-o StrictHostKeyChecking=no"
|
||||||
1
tests/pubkey
Normal file
1
tests/pubkey
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAAxfDLK7wu1ITTMV8gIzImO+KkXsjByvN7gYebqb5e+ stobbsm@ed25591
|
||||||
@@ -2,4 +2,9 @@
|
|||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
remote_user: root
|
remote_user: root
|
||||||
roles:
|
roles:
|
||||||
- ansible_role_package
|
- role: ansible_role_package
|
||||||
|
vars:
|
||||||
|
use_local: false
|
||||||
|
packages:
|
||||||
|
- air
|
||||||
|
- ansible-language-server
|
||||||
|
|||||||
Reference in New Issue
Block a user