Quellcode durchsuchen

clean up and add a README

Grega Bremec vor 2 Monaten
Ursprung
Commit
fca914436c

+ 14 - 0
README.md

@@ -0,0 +1,14 @@
+== Ansible Examples ==
+
+This Git repository contains a couple of branches that showcase some of the key principles in designing and developing playbooks and roles.
+
+More information on the settings and ideas demonstrated is available in each branch.
+
+The branches are:
+
+* `standard-playbook` - a standard UNIX service (configurable via text files) deployment playbook
+* `standard-role` - the same, but converted into a generic role
+* `nonstandard-playbook` - a non-standard service (requiring the use of specific modules) deployment playbook
+* `misc` - some of the demos that have not been classified yet, or are too small to have a branch of their own
+
+Enjoy!

+ 0 - 34
defaults/main.yml

@@ -1,34 +0,0 @@
----
-# list any programs (full command) that can be used to validate configuration,
-# in this variable
-test_programs: []
-
-# the name of the service that needs to be manipulated by the tasks and handlers
-# TODO: maybe make service a list
-service: null
-
-# the firewalld service to open in the public zone
-# TODO: maybe make fwsvc a list
-fwsvc: null
-
-# the list of packages that need to be installed on the target machine
-packages: []
-
-# any configuration files that will be processed as templates and published to
-# the remote machine; each element of the variable must look like this:
-#  - src: the path to the template file, relative to playbook or role directory
-#    dest: destination path (absolute) on the target system
-#    owner: file owner, when deployed on target
-#    group: group the file should belong to
-#    mode: permissions on the file (octal!)
-configs: []
-
-# any configuration files that will be copied without modification; each
-# element of the variable must look like this:
-#  - src: the path to the template file, relative to playbook or role directory
-#    dest: destination path (absolute) on the target system
-#    owner: file owner, when deployed on target
-#    group: group the file should belong to
-#    mode: permissions on the file (octal!)
-staticfiles: []
-...

+ 0 - 13
handlers/main.yml

@@ -1,13 +0,0 @@
----
-- name: test configuration validity
-  listen: them handlerz
-  command: "{{ item }}"
-  changed_when: false
-  loop: "{{ test_programs }}"
-
-- name: restart the service
-  listen: them handlerz
-  service:
-    name: "{{ service }}"
-    state: restarted
-...

+ 0 - 37
meta/main.yml

@@ -1,37 +0,0 @@
----
-galaxy_info:
-  role_name: deploystuff
-  namespace: myroles
-
-  author: Grega Bremec <gbremec@redhat.com>
-  description: this is a generic deploy-anything role
-  company: Red Hat
-
-  license: BSD
-
-  min_ansible_version: 2.9
-
-  platforms:
-    - name: RHEL
-      versions:
-        - 8
-        - 9
-
-dependencies: []
-
-#  - role: mariadb
-#    n: 1
-#    vars:
-#      mode: replicated
-#      role: master
-#      parameter_x: abc
-#      parameter_y: "{{ variable_we_use }}"
-#
-#  - role: mariadb
-#    n: 2
-#    vars:
-#      mode: replicated
-#      role: slave
-#      parameter_x: abc
-#      parameter_y: "{{ variable_we_use }}"
-...

+ 0 - 7
molecule/default/converge.yml

@@ -1,7 +0,0 @@
----
-- name: Converge
-  hosts: all
-  tasks:
-    - name: "Include myroles.deploystuff"
-      include_role:
-        name: "myroles.deploystuff"

+ 0 - 29
molecule/default/molecule.yml

@@ -1,29 +0,0 @@
----
-dependency:
-  name: galaxy
-driver:
-  name: podman
-platforms:
-  - name: instance
-    image: registry.access.redhat.com/ubi8/python-39:latest
-    tmpfs:
-      - /run
-      - /tmp
-    volumes:
-      - /sys/fs/cgroup:/sys/fs/cgroup:ro
-    capabilities:
-      - SYS_ADMIN
-    pre_build_image: true
-provisioner:
-  name: ansible
-  config_options:
-    defaults:
-      interpreter_python: auto_silent
-    ssh_connection:
-      pipelining: false
-verifier:
-  name: ansible
-lint: |
-  set -e
-  yamllint .
-  ansible-lint .

+ 0 - 10
molecule/default/verify.yml

@@ -1,10 +0,0 @@
----
-# This is an example playbook to execute Ansible tests.
-
-- name: Verify
-  hosts: all
-  gather_facts: false
-  tasks:
-  - name: Example assertion
-    assert:
-      that: true

+ 0 - 51
tasks/main.yml

@@ -1,51 +0,0 @@
----
-- name: ensure the software is there
-  become: true
-  yum:
-    name: "{{ packages }}"
-    state: present
-
-- name: process any templates and publish them
-  become: true
-  template:
-    src: "{{ item.src }}"
-    dest: "{{ item.dest }}"
-    owner: "{{ item.owner | default(omit) }}"
-    group: "{{ item.group | default(omit) }}"
-    mode: "{{ item.mode | default(omit) }}"
-  notify:
-    - test configuration validity
-    - restart the service
-  loop: "{{ configs }}"
-
-- name: deploy the static files as well
-  become: true
-  copy:
-    src: "{{ item.src }}"
-    dest: "{{ item.dest }}"
-    owner: "{{ item.owner | default(omit) }}"
-    group: "{{ item.group | default(omit) }}"
-    mode: "{{ item.mode | default(omit) }}"
-  notify: them handlerz
-  loop: "{{ staticfiles }}"
-
-- name: execute handlers if necessary
-  meta: flush_handlers
-
-- name: ensure the service is started and enabled to start automatically
-  become: true
-  service:
-    name: "{{ service }}"
-    state: started
-    enabled: true
-  when: service != None
-
-- name: ensure firewall is open for the service
-  become: true
-  firewalld:
-    service: "{{ fwsvc }}"
-    state: enabled
-    immediate: true
-    permanent: true
-  when: fwsvc != None
-...

+ 0 - 7
tests/deploy-apache.yml

@@ -1,7 +0,0 @@
----
-- hosts: all
-  vars_files:
-    - vars.yml
-  roles:
-    - myroles.deploystuff
-...

+ 0 - 5
tests/do-nothing.yml

@@ -1,5 +0,0 @@
----
-- hosts: all
-  roles:
-    - myroles.deploystuff
-...

+ 0 - 1
tests/inventory

@@ -1 +0,0 @@
-servera.lab.example.com ansible_user=devops

+ 0 - 42
tests/rollback.yml

@@ -1,42 +0,0 @@
----
-- hosts: all
-  become: yes
-  vars_files:
-    - vars.yml
-  tasks:
-    - name: ensure the service is stopped
-      service:
-        name: "{{ service }}"
-        state: stopped
-        enabled: no
-      when: service != None
-      ignore_errors: true
-
-    - name: ensure the firewall ports are closed
-      firewalld:
-        service: "{{ fwsvc }}"
-        state: disabled
-        immediate: true
-        permanent: true
-      when: fwsvc != None
-      ignore_errors: true
-
-    - name: remove the packages
-      yum:
-        name: "{{ packages }}"
-        state: absent
-
-    - name: remove any published templates
-      file:
-        path: "{{ item.dest }}"
-        state: absent
-      loop: "{{ configs }}"
-      when: configs is defined
-
-    - name: remove any static files
-      file:
-        path: "{{ item.dest }}"
-        state: absent
-      loop: "{{ staticfiles }}"
-      when: staticfiles is defined
-...

+ 0 - 6
tests/vars.yml

@@ -1,6 +0,0 @@
-packages:
-  - httpd
-test_programs:
-  - apachectl configtest
-service: httpd
-fwsvc: http