<commit_before>require 'json'

# Configure directories
consul_directories = []
consul_directories << node[:consul][:config_dir]
consul_directories << "/var/lib/consul"

# Select service user & group
case node[:consul][:init_style]
when 'runit'
  consul_user = node[:consul][:service_user]
  consul_group = node[:consul][:service_group]
  consul_directories << "/var/log/consul"
else
  consul_user = 'root'
  consul_group = 'root'
end

# Create service user
unless consul_user == 'root'
  user "consul service user: #{consul_user}" do
    username  consul_user
    home      "/dev/null"
    shell     "/bin/false"
    comment   "consul service user"
  end
end

# Create service group
unless consul_group == 'root'
  group "consul service group: #{consul_group}" do
    group_name  consul_group
    members     consul_user
    append      true
  end
end

# Create service directories<commit_msg>refactor user/group creation<commit_after>require 'json'

# Configure directories
consul_directories = []
consul_directories << node[:consul][:config_dir]
consul_directories << "/var/lib/consul"

# Select service user & group
case node[:consul][:init_style]
when 'runit'
  consul_user = node[:consul][:service_user]
  consul_group = node[:consul][:service_group]
  consul_directories << "/var/log/consul"
else
  consul_user = 'root'
  consul_group = 'root'
end

# Create service user
user "consul service user: #{consul_user}" do
  not_if { consul_user == 'root' }
  username  consul_user
  home      "/dev/null"
  shell     "/bin/false"
  comment   "consul service user"
end

# Create service group
group "consul service group: #{consul_group}" do
  not_if { consul_group == 'root' }
  group_name  consul_group
  members     consul_user
  append      true
end

# Create service directories
{'fraction_non_alphanumeric': 0.10824453168816602, 'fraction_numerical': 0.0, 'mean_word_length': 4.27810650887574, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2836699', 'n_tokens_mistral': 608, 'n_tokens_neox': 601, 'n_words': 151}