Skip to content

Commit

Permalink
Merge pull request #4 from rainerleber/feature/fix_galaxy_inclusion
Browse files Browse the repository at this point in the history
fix lint reference, add runtime
  • Loading branch information
sean-freeman authored May 16, 2022
2 parents 0684c48 + 0292006 commit a7ad12e
Show file tree
Hide file tree
Showing 66 changed files with 727 additions and 655 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ansible-lint-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---

skip_list:
- command-instead-of-module
- command-instead-of-shell
- line-length
- risky-shell-pipe
- no-changed-when
- no-handler
- ignore-errors
15 changes: 4 additions & 11 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,9 @@ jobs:

steps:
- uses: actions/checkout@v2

- name: Lint Ansible Playbook
uses: ansible/ansible-lint-action@master
with:
targets: |
./
./roles
override-deps: |
ansible==4.8.0
ansible-core==2.11.6
ansible-lint==5.2.1
- uses: actions/setup-python@v3
- run: |
pip3 install ansible-lint
ansible-lint -p roles/ -c .github/workflows/ansible-lint-config
# Static: use Ansible Community Edition 4.8.0, with lowest compatible Ansible Core 2.11.6 and use Ansible-lint 5.2.1
14 changes: 14 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
======================================
Community SAP_OPERATIONS Release Notes
======================================

.. contents:: Topics


v0.9.0
======

Release Summary
---------------

This is the first release of the ``community.sap_operations`` collection. It is the initial relase for the ``community.sap_operations`` collection
22 changes: 22 additions & 0 deletions changelogs/.plugin-cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
objects:
role: {}
plugins:
become: {}
cache: {}
callback: {}
cliconf: {}
connection: {}
httpapi: {}
inventory: {}
lookup: {}
module:
sap_pyrfc:
description: Execute RFC calls
name: sap_pyrfc
namespace: ''
version_added: 0.1.0
netconf: {}
shell: {}
strategy: {}
vars: {}
version: 1.0.0
9 changes: 9 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ancestor: null
releases:
0.9.0:
changes:
release_summary: 'This is the first release of the ``community.sap_operations``
collection. It is the initial relase for the collection'
fragments:
- 0.9.0.yml
release_date: '2022-05-16'
30 changes: 30 additions & 0 deletions changelogs/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
changelog_filename_template: ../CHANGELOG.rst
changelog_filename_version_depth: 0
changes_file: changelog.yaml
changes_format: combined
keep_fragments: false
mention_ancestor: true
flatmap: true
new_plugins_after_name: removed_features
notesdir: fragments
prelude_section_name: release_summary
prelude_section_title: Release Summary
sections:
- - major_changes
- Major Changes
- - minor_changes
- Minor Changes
- - breaking_changes
- Breaking Changes / Porting Guide
- - deprecated_features
- Deprecated Features
- - removed_features
- Removed Features (previously deprecated)
- - security_fixes
- Security Fixes
- - bugfixes
- Bugfixes
- - known_issues
- Known Issues
title: Community SAP_OPERATIONS
trivial_section_name: trivial
Empty file added changelogs/fragments/.keep
Empty file.
2 changes: 2 additions & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
requires_ansible: '>=2.9.10'
21 changes: 21 additions & 0 deletions plugins/modules/sap_pyrfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@

__metaclass__ = type

DOCUMENTATION = r'''
---
module: sap_pyrfc
short_description: Execute RFC calls
version_added: "0.1.0"
description: This module executes RFC calls.
options:
function:
description: The system ID.
type: str
required: true
parameters:
description: The parameters for the function.
type: dict
required: true
connection:
description: The connection parameters.
type: dict
required: true
'''

EXAMPLES = '''
sap_pyrfc:
function: STFC_CONNECTION
Expand Down
2 changes: 1 addition & 1 deletion roles/os_ansible_user/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ os_ansible_user_uid: ""
os_ansible_user_gid: ""
os_ansible_user_keyfile: id_ecdsa.pub

os_ansible_user_force_recreate: yes
os_ansible_user_force_recreate: true
22 changes: 11 additions & 11 deletions roles/os_ansible_user/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
- name: Remove existing {{ os_ansible_user_userid }}
block:
- name: Kill all processes under {{ os_ansible_user_userid }}
ignore_errors: yes
shell: |
ignore_errors: true
ansible.builtin.shell: |
killall -u {{ os_ansible_user_userid }}
- name: Remove {{ os_ansible_user_userid }}
user:
ansible.builtin.user:
name: '{{ os_ansible_user_userid }}'
state: absent
remove: yes
force: yes
remove: true
force: true

- name: Remove {{ os_ansible_user_userid }} group
group:
ansible.builtin.group:
name: '{{ os_ansible_user_userid }}'
state: absent
when: os_ansible_user_force_recreate

- name: Create {{ os_ansible_user_userid }} group
group:
ansible.builtin.group:
name: '{{ os_ansible_user_userid }}'
gid: '{{ os_ansible_user_gid }}'
state: present

- name: Create {{ os_ansible_user_userid }}
user:
ansible.builtin.user:
name: '{{ os_ansible_user_userid }}'
comment: "Ansible User"
uid: '{{ os_ansible_user_uid }}'
group: '{{ os_ansible_user_userid }}'
groups: "{{ os_ansible_user_userid }},wheel"

- name: Add to sudoers NOPASSWD
shell: |
ansible.builtin.shell: |
echo '{{ os_ansible_user_password }}' | passwd --stdin {{ os_ansible_user_userid }}
echo -e '{{ os_ansible_user_userid }}\tALL=(ALL)\tNOPASSWD: ALL' > /etc/sudoers.d/{{ os_ansible_user_userid }}
- name: Add key
authorized_key:
ansible.posix.authorized_key:
user: '{{ os_ansible_user_userid }}'
state: present
manage_dir: yes
manage_dir: true
key: "{{ lookup('file', item) }}"
with_fileglob:
- /home/{{ os_ansible_user_userid }}/.ssh/{{ os_ansible_user_keyfile }}
2 changes: 1 addition & 1 deletion roles/os_etchosts/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SAP OS Tools - /etc/hosts

- name: SAP OS Tools - /etc/hosts
include_tasks: update_etchosts.yml
ansible.builtin.include_tasks: update_etchosts.yml
loop: "{{ os_etchosts_entries }}"
loop_control:
loop_var: passed_entry
6 changes: 3 additions & 3 deletions roles/os_etchosts/tasks/update_etchosts.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
- name: SAP OS Tools - /etc/hosts - Split passed entry
set_fact:
ansible.builtin.set_fact:
passed_ip: "{{ passed_entry.split()[0] }}"
passed_host: "{{ passed_entry.split()[1] }}"

- name: SAP OS Tools - /etc/hosts - Deduplicate values from /etc/hosts
lineinfile:
ansible.builtin.lineinfile:
path: /etc/hosts
create: false
regexp: (?i)^\s*{{ passed_ip }}\s+
state: absent

- name: SAP OS Tools - /etc/hosts - Update
lineinfile:
ansible.builtin.lineinfile:
path: /etc/hosts
line: "{{ passed_ip }}{{ os_etchosts_delimiter }}{{ passed_host }}.{{ os_etchosts_fqdn }}{{ os_etchosts_delimiter }}{{ passed_host }}"
2 changes: 1 addition & 1 deletion roles/os_knownhosts/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ssh_known_hosts_command: "ssh-keyscan -T 10"
ssh_known_hosts_file: "{{ lookup('env','HOME') + '/.ssh/known_hosts' }}"
ssh_known_hosts: "{{ groups['all'] }}"
ssh_known_hosts: "{{ groups['all'] }}"
4 changes: 2 additions & 2 deletions roles/os_knownhosts/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
---

- name: Scan ssh public key for each host
shell: "ssh-keyscan {{ item }},`dig +short {{ item }}`"
ansible.builtin.shell: "ssh-keyscan {{ item }},`dig +short {{ item }}`"
with_items: "{{ ssh_known_hosts }}"
register: ssh_known_host_results
ignore_errors: true

- name: Add/update public key in the '{{ ssh_known_hosts_file }}'
known_hosts:
ansible.builtin.known_hosts:
name: "{{ item.item }}"
key: "{{ item.stdout }}"
path: "{{ ssh_known_hosts_file }}"
Expand Down
2 changes: 1 addition & 1 deletion roles/sap_control/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ stop_sap_hana_list:
- sap_control_function_current: "hana_stop"

start_sap_hana_list:
- sap_control_function_current: "hana_start"
- sap_control_function_current: "hana_start"
6 changes: 3 additions & 3 deletions roles/sap_control/tasks/functions/cleanipc.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
- name: SAP {{ sap_control_name_header }} - Cleanipc {{ passed_sap_nr }}
shell: |
ansible.builtin.shell: |
source ~/.profile && cleanipc {{ passed_sap_nr }} remove
args:
executable: /bin/bash
become: yes
become: true
become_method: sudo
become_user: "{{ passed_sap_sid | lower }}adm"
register: cleanipc
changed_when:
- "'Number of IPC-Objects...........: 0' not in cleanipc.stdout"
- "'Number of IPC-Objects...........: 0' not in cleanipc.stdout"
17 changes: 8 additions & 9 deletions roles/sap_control/tasks/functions/restart_sapstartsrv.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
# Restart sapstartsrv


# Get number of sapstartsrv processes running for {{ passed_sap_sid }}-{{ passed_sap_nr }}
- name: SAPstartsrv - Get number of sapstartsrv processes running for {{ passed_sap_sid }}-{{ passed_sap_nr }}
shell: |
ansible.builtin.shell: |
ps -ef | grep {{ passed_sap_sid }} | grep {{ passed_sap_nr }} | grep sapstartsrv | awk '{ print $8 }'
register: num_of_sapstartsrv_reg

- name: SAPstartsrv - Set fact for number of sapstartsrv
set_fact:
ansible.builtin.set_fact:
num_of_sapstartsrv: "{{ num_of_sapstartsrv_reg.stdout.split() }}"

# Stop sapstartsrv
- name: SAPstartsrv - Stop sapstartsrv {{ passed_sap_sid }}-{{ passed_sap_nr }}
shell: |
ansible.builtin.shell: |
source ~/.profile && cdexe; sapcontrol -nr {{ passed_sap_nr }} -function StopService {{ passed_sap_sid }}
args:
executable: /bin/bash
become: yes
become: true
become_user: "{{ passed_sap_sid | lower }}adm"
register: sap_stop_sapstartsrv
loop: "{{ num_of_sapstartsrv }}"
delay: 2

# Start sapstartsrv
- name: SAPstartsrv - Start sapstartsrv {{ passed_sap_sid }}-{{ passed_sap_nr }}
shell: |
ansible.builtin.shell: |
source ~/.profile && cdexe; sapcontrol -nr {{ passed_sap_nr }} -function StartService {{ passed_sap_sid }}
args:
executable: /bin/bash
become: yes
become: true
become_user: "{{ passed_sap_sid | lower }}adm"
register: sap_start_sapstartsrv

- name: SAPstartsrv - Wait for 10 seconds for sapstartsrv to initialize
pause:
ansible.builtin.pause:
seconds: 10
8 changes: 4 additions & 4 deletions roles/sap_control/tasks/functions/sapstartsrv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@

# Check sapstartsrv
- name: SAPstartsrv - Check sapstartsrv
shell: |
ansible.builtin.shell: |
source ~/.profile && cdexe; sapcontrol -nr {{ passed_sap_nr }} -function GetSystemInstanceList
args:
executable: /bin/bash
become: yes
become: true
become_user: "{{ passed_sap_sid | lower }}adm"
ignore_errors: yes
ignore_errors: true
register: check_sapstartsrv
changed_when:
- ('FAIL' in check_sapstartsrv.stdout)

# Check sapstartsrv
- name: SAPstartsrv - Restart sapstartsrv
include_tasks: restart_sapstartsrv.yml
ansible.builtin.include_tasks: restart_sapstartsrv.yml
when:
- ('FAIL' in check_sapstartsrv.stdout)
Loading

0 comments on commit a7ad12e

Please sign in to comment.