Commit 1da7377c authored by Sergey Boldyrev's avatar Sergey Boldyrev
Browse files

formatting

parent ce0fd3c9
......@@ -2,7 +2,7 @@
This cookbook enables the configuration of generic [Chef resources](https://docs.chef.io/resources.html) by attributes.
The following resource list includes all Chef resources mapped by default:
The following resource list includes all Chef resources mapped by default:
```
apt_repository
......@@ -65,10 +65,10 @@ name 'ntpd'
description 'ntpd configuration'
run_list( 'recipe[base]' )
default_attributes(
##
# PACKAGES
#
#
package: [ 'ntp','ntpdate' ],
# Remove the default NTP service on CentOS
......@@ -78,9 +78,9 @@ default_attributes(
# CONFIGURATION FILES
#
file: {
##
# Time Synchronisation
# Time Synchronisation
#
'/etc/ntp.conf': {
content: %(
......@@ -104,13 +104,13 @@ default_attributes(
systemd_unit: {
##
# Set timezone at boot
# Set timezone at boot
#
'set-timezone.service': {
content: '
[Unit]
Description=Set the time zone to Europe/Berlin
[Service]
ExecStart=/usr/bin/timedatectl set-timezone Europe/Berlin
RemainAfterExit=yes
......@@ -122,7 +122,7 @@ default_attributes(
# Disable /etc/init.d/ntp if present
'ntp.service': { action: [:stop, :disable] },
'ntpd.service': {
'ntpd.service': {
content: %(
[Unit]
Description=Network Time Service
......@@ -154,16 +154,16 @@ To enable this feature one has to configure an additional attribute _template_fi
#... part of default_attributes(
file: {
##
# Time Synchronisation
# Time Synchronisation
#
"<%= node['ntp_config_location'] %>" => {
content: %q<
<% node['ntp_servers'].each do |server| %>
<% node['ntp_servers'].each do |server| %>
<%- %>server = <%= server -%>
<%- end %>
<% node['ntp_config_extra'].each do |conf| %>
<%- end %>
<% node['ntp_config_extra'].each do |conf| %>
<%=- conf -%>
<% end %>
<% end %>
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
restrict 127.0.0.1
......@@ -175,10 +175,10 @@ To enable this feature one has to configure an additional attribute _template_fi
"ntp_config_location" => "/etc/ntp.conf",
"ntp_servers" => ["0.pool.ntp.org","1.pool.ntp.org","2.pool.ntp.org","3.pool.ntp.org"],
"ntp_config_extra" => ["driftfile /var/lib/ntp/ntp.drift",
"statistics loopstats peerstats clockstats",
"filegen loopstats file loopstats type day enable",
"filegen peerstats file peerstats type day enable",
"filegen clockstats file clockstats type day enable"]
"statistics loopstats peerstats clockstats",
"filegen loopstats file loopstats type day enable",
"filegen peerstats file peerstats type day enable",
"filegen clockstats file clockstats type day enable"]
#... end of default_attributes(
```
## License
......
......@@ -74,9 +74,9 @@ resource_list.each do |resource|
# Get config fields which are to be expanded via ERB
case conf['template_fields']
when String
template_fields = [conf['template_fields']]
template_fields = [conf['template_fields']]
when Chef::Node::ImmutableArray
template_fields = conf['template_fields']
else
......@@ -93,14 +93,14 @@ resource_list.each do |resource|
conf.each do |key,value|
# Expand config field via ERB if specified
value=ERB.new(value,nil,'-').result_with_hash(node:node) if template_fields.include?key
case key
when 'content'
if resource.eql? 'file'
# Disable the header comment by attribute
banner = if not node[resource][name].has_key? 'banner'
# Disable the header comment by attribute
banner = if not node[resource][name].has_key? 'banner'
true
else
node[resource][name]['banner']
......@@ -108,7 +108,7 @@ resource_list.each do |resource|
# Add a banner to indicate that the written file is
# managed by Chef
if banner
if banner
value = "
#
# DO NOT CHANGE THIS FILE MANUALLY!
......@@ -126,7 +126,7 @@ resource_list.each do |resource|
value = value[1..-1] if value[0] =~ /^$/
value = value.join("\n") << "\n"
send(key,value)
when 'template','not_if','only_if'
send(key, *value)
......
name 'chef_client'
description 'Install the Chef client '
run_list(
run_list(
'recipe[base]',
)
default_attributes(
......
name 'mariadb'
description 'Install and configure MariaDB'
run_list(
run_list(
'recipe[base]',
)
default_attributes(
......@@ -34,7 +34,7 @@ default_attributes(
firewall-cmd --zone=public --add-service=mysql --permanent
firewall-cmd --reload
',
not_if: [ 'firewall-cmd --zone=public --query-service=mysql' ]
not_if: [ 'firewall-cmd --zone=public --query-service=mysql' ]
}
},
systemd_unit: {
......
......@@ -19,7 +19,7 @@ default_attributes(
##
# PACKAGES
#
#
yum_package: {
'munge': { notifies: [ :create, 'file[/etc/munge/munge.key]' ] },
},
......
......@@ -2,10 +2,10 @@ name 'ntpd'
description 'NTPD configuration'
run_list( 'recipe[base]' )
default_attributes(
##
# PACKAGES
#
#
package: [ 'ntp','ntpdate' ],
# Remove the default NTP service on CentOS
......@@ -15,9 +15,9 @@ default_attributes(
# CONFIGURATION FILES
#
file: {
##
# Time Synchronisation
# Time Synchronisation
#
'/etc/ntp.conf': {
content: %(
......@@ -45,13 +45,13 @@ default_attributes(
systemd_unit: {
##
# Set timezone at boot
# Set timezone at boot
#
'set-timezone.service': {
content: '
[Unit]
Description=Set the time zone to Europe/Berlin
[Service]
ExecStart=/usr/bin/timedatectl set-timezone Europe/Berlin
RemainAfterExit=yes
......@@ -63,7 +63,7 @@ default_attributes(
# Disable /etc/init.d/ntp if present
'ntp.service': { action: [:stop, :disable] },
'ntpd.service': {
'ntpd.service': {
content: %(
[Unit]
Description=Network Time Service
......
name 'slurm'
description 'SLURM Generic Configuration'
run_list(
run_list(
'recipe[base]',
'role[munged]'
)
default_attributes(
##
# Groups
#
......@@ -32,22 +32,22 @@ default_attributes(
##
# Slurm cluster users
#
spock: {
spock: {
uid: 1111,
home: '/network/spock',
shell: '/bin/bash'
},
sulu: {
sulu: {
uid: 1112,
home: '/network/sulu',
shell: '/bin/bash'
},
kirk: {
kirk: {
uid: 1113,
home: '/network/kirk',
shell: '/bin/bash'
},
uhura: {
uhura: {
uid: 1114,
home: '/network/uhura',
shell: '/bin/bash'
......@@ -89,7 +89,7 @@ default_attributes(
##
# PACKAGES
#
#
yum_package: {
'nfs-utils': {},
'slurm': {},
......
name 'slurmctld'
description 'Slurm Cluster Controller deployment'
run_list(
run_list(
'recipe[base]',
'role[slurm]'
)
default_attributes(
##
# DIRECTORIES
......@@ -16,7 +16,7 @@ default_attributes(
#
'/var/lib/slurm/ctld': { owner: 'slurm', recursive: true },
'/var/spool/slurm/ctld': { owner: 'slurm', recursive: true },
##
# User directories on shared storage
#
......@@ -33,7 +33,7 @@ default_attributes(
##
# NFS shares configuration
#
'/etc/exports' => {
'/etc/exports' => {
content: "/etc/slurm lx*(ro,sync,no_subtree_check)\n/network lx*(rw)\n",
notifies: [ :restart, 'systemd_unit[nfs-server.service]' ]
},
......@@ -43,16 +43,16 @@ default_attributes(
'/etc/firewalld/services/slurmctld.xml': {
content: '
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>slurmctld</short>
<description>SLURM Workload Manager</description>
<port protocol="udp" port="6817"/>
<port protocol="tcp" port="6817"/>
<port protocol="udp" port="6818"/>
<port protocol="tcp" port="6818"/>
<port protocol="udp" port="7321"/>
<port protocol="tcp" port="7321"/>
</service>
<service>
<short>slurmctld</short>
<description>SLURM Workload Manager</description>
<port protocol="udp" port="6817"/>
<port protocol="tcp" port="6817"/>
<port protocol="udp" port="6818"/>
<port protocol="tcp" port="6818"/>
<port protocol="udp" port="7321"/>
<port protocol="tcp" port="7321"/>
</service>
',
notifies: [ :run, 'execute[firewall-cmd-add-slurmctld]' ]
}
......@@ -89,7 +89,7 @@ default_attributes(
##
# PACKAGES
#
#
yum_package: {
'slurm-slurmdbd': {}
},
......
name 'slurmd'
description 'SLURM execution node'
run_list(
run_list(
'recipe[base]',
'role[slurm]'
)
......
name 'ssh'
description 'SSH configuration for testing'
run_list(
run_list(
'recipe[base]',
'role[accounts]'
)
default_attributes(
directory: {
'/home/kirk/.ssh/': { mode: '0700' }
'/home/kirk/.ssh/': { mode: '0700' }
},
file: {
##
# Global SSH daemon configuration
#
#
sshd_config: {
path: '/etc/ssh/sshd_config',
content: '
......
......@@ -2,24 +2,24 @@ name "systemd"
description "Systemd configuration for testing"
run_list( "recipe[base]" )
default_attributes(
package: [
'systemd-networkd',
'systemd-resolved'
],
directory: {
'/etc/systemd/network': { recursive: true },
'/etc/systemd/journald.conf.d': { recursive: true }
},
file: {
'/etc/systemd/network/50-dhcp.network': {
content: '
[Match]
Name=eth0
[Network]
DHCP=yes
'
......@@ -38,9 +38,9 @@ default_attributes(
',
notifies: [ :restart, 'systemd_unit[systemd-resolved.service]' ]
},
##
# Configure journald to store log file persistently
# Configure journald to store log file persistently
#
'/etc/systemd/journald.conf.d/journal-storage.conf': {
content: '
......@@ -66,18 +66,18 @@ default_attributes(
systemd_unit: {
'systemd-networkd.service': { action: [:enable,:start] },
'systemd-resolved.service': { action: [:enable,:start] },
'systemd-logind.service': { action: :enable },
'systemd-journald.service': { action: [:enable,:start] },
'set-timezone.service': {
content: '
[Unit]
Description=Set the time zone to Europe/Berlin
[Service]
ExecStart=/usr/bin/timedatectl set-timezone Europe/Berlin
RemainAfterExit=yes
......
......@@ -2,7 +2,7 @@ name 'template'
description 'Template configuration for testing'
run_list( 'recipe[base]' )
default_attributes(
directory: {
'/var/cache/chef': { recursive: true }
},
......@@ -23,7 +23,7 @@ default_attributes(
'/tmp/template.txt': {
local: true,
source: '/var/cache/chef/template.erb',
variables: {
variables: {
one: 'hello',
two: 'world'
}
......
name 'yum_epel'
description 'EPEL Yum package repository'
run_list(
run_list(
'recipe[base]',
)
default_attributes(
......
......@@ -18,7 +18,7 @@ default_attributes(
'/etc/selinux/config': {
content: '
SELINUX=disabled
SELINUXTYPE=targeted
SELINUXTYPE=targeted
'
},
##
......
name 'yum_repo'
description 'Configure a local Yum package repository'
run_list(
run_list(
'recipe[base]',
'role[yum_mirror]'
)
......
  • @s.boldyrev So ... now we can no longer simply merge/rebase to and from upstream https://github.com/vpenso/chef-base

    And you directly pushed to master. What kind of tool did you use for formatting? With what options?

    I don't mind having a common style but this has different implications in this case.

  • @j.knedlik Sorry, Jan, I couldn't imagine, that this repository is (still) somehow connected with any external source. I know it was a clone from Victor's own repo, several years ago, but I thought, it lived now "its own life" since it was here. What I am used to, is that our repos are ours and everybody can edit it. I actually did nothing serious, just removed spaces at the end of lines and some tabs, as you can see, don't understand why it makes so much trouble, but you may just cancel this commit; I guess there is some command in Git to "revert" to the previous version (never used it myself). Actually I don't work with this Cookbook and shouldn't touch it, as I see now.

  • @s.boldyrev Thats understandable. I think this repo just sat around minding its own, but I think its good to share our changes upstream. Please don't misunderstand, its still everyones repo and fine to get in changes. Maybe just via a PR/MR on this repo as we can and should get stuff upstream.

    I know you did nothing bad, I am actually always open for coding standards and the like. It was just unfortunate that following your change all PR/MR into upstream would be filled with these changes as well, making the real changes much less clear. I think If you'd like to have them it would be better to get them into upstream first, from a branch of this and a fork in github.

    I will freeze master and fix it around to remove HEAD, but you will need to fix your own repository as it will invalidate your master.

    Contributions are always welcome and encouraged, maybe not just in the 'just push to master'-way, especially not in this repo.

  • @j.knedlik Ich habe dir auch per E-Mail geantwortet :)
    Wie gesagt, war das keine echte Kodierung, auch keine "coding standards",
    einfach ein bisschen Ästhetik, unter dem Motto "Why not",
    wenn ich nach deiner Änderung nachgeschaut hatte.
    Schmeiß es einfach weg, wenn es für euch so besser ist.

    Edited by Sergey Boldyrev
  • OK, sorry and thanks.

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment