<commit_before># f5-cookbook

A set of resources for managing F5 load balancers. Currently a WIP, but it will create VIPs and pools, and add nodes to pools

## Requirements

### Platforms

- RHEL/Fedora and derivatives
- Debian/Ubuntu and derivatives
- Windows [2012.R2, 2016]

### Chef

- Chef 12.7+

### Cookbooks

- none

## Attributes

- `node['f5']['gem_version']` - Sets the version of the gem that will be installed via the resource
- `node['f5']['enabled_status']` - Can take one of three values:
  - `:manual` - the default, the `f5_pool` resource does not touch the node's enabled status on load balancer, allowing it to be managed manually on the load balancer
  - `:disabled` - if a node does not exist or does exist but is enabled, the load balancer will be asked to disable the node
  - `:enabled` - if a node does not exist or does exist but is disabled, the load balancer will be asked to enable the node

## Usage

Your node will also need access to the credentials for the load balancer either in the attributes or a data bag:

If you're using a data bag, call it `f5` and the default item is called `default`.

```
$ knife data bag show f5 default
Unencrypted data bag detected, ignoring any provided secret options.
host:     lb1.example.com
id:       default
password: <PASSWORD>
username: chef-api
```

Or, if no data bag is found, attributes are used

```
default[:f5][:credentials][:default] = {
  host: "lb1.example.com",
  username: "chef-api",
  password: "<PASSWORD>"
}
```

### Resources

In an application's recipe:

```ruby
# Creates the pool if missing and adds this node to the pool
# (currently using node.ipaddress and node.fqdn for the node)
f5_pool 'mypool' do
  host 'value'
  port 'value'
  lb_method 'method' # LB_METHOD_ROUND_ROBIN default
end

# Creates the VIP if missing
f5_vip 'myvip' do
  address 'vipaddress' # IPv4 or FQDN, see below
  port 'vipport'
  protocol 'protocol' # TCP default
  pool 'mypool'

  # this is optional; defaults to :manual so won't touch your setting
  #                   unless you specify one of the valid options.
  snat_pool :automap

  # this is optional; defaults to :manual so won't touch your setting
  #                   unless you specify one of the valid options.
  #                   :none disables the firewall_policy,
  #                   anything else is a named firewall_policy
  enforced_firewall_policy

  # this is optional; defaults to :manual so won't touch your setting
  #                   unless you specify one of the valid options.
  #                   :none disables the firewall_policy,
  #                   anything else is a named firewall_policy
  staged_firewall_policy
  
  # this is optional; If this VIP has IRules on the F5, this resource
  #                   will remove them and insert exactly what is specified
  #                   here. The attribute takes in an array of irules. The order 
  #                   describes the priority of the irules.
  #                   When changing priority of IRules, be aware that the F5
  #                   doesn't provide an API for re-ordering associations therefore
  #                   the re-ordered rules must be deleted then re-added in the correct
  #                   order.
  irules %w(test-irule test-irule-2)
  
  # this is optional; Sets the http profile of the VIP. The default value is `nil`.
  #                   When value is `nil` it not modify the http profile. Setting to 
  #                   `:none` will remove the http profile. Otherwise
  #                   it sets the http profile. Note, the HTTP Profile must already
  #                   exist on the f5.
  http_profile :none
end

# Create a F5 monitor template
f5_monitor 'test-monitor' do 
  # Required properties
  template_type 'TTYPE_HTTP' # F5 template type
  parent_template 'http'
  interval 5 # frequency to check in seconds<commit_msg>fix wording<commit_after># f5-cookbook

A set of resources for managing F5 load balancers. Currently a WIP, but it will create VIPs and pools, and add nodes to pools

## Requirements

### Platforms

- RHEL/Fedora and derivatives
- Debian/Ubuntu and derivatives
- Windows [2012.R2, 2016]

### Chef

- Chef 12.7+

### Cookbooks

- none

## Attributes

- `node['f5']['gem_version']` - Sets the version of the gem that will be installed via the resource
- `node['f5']['enabled_status']` - Can take one of three values:
  - `:manual` - the default, the `f5_pool` resource does not touch the node's enabled status on load balancer, allowing it to be managed manually on the load balancer
  - `:disabled` - if a node does not exist or does exist but is enabled, the load balancer will be asked to disable the node
  - `:enabled` - if a node does not exist or does exist but is disabled, the load balancer will be asked to enable the node

## Usage

Your node will also need access to the credentials for the load balancer either in the attributes or a data bag:

If you're using a data bag, call it `f5` and the default item is called `default`.

```
$ knife data bag show f5 default
Unencrypted data bag detected, ignoring any provided secret options.
host:     lb1.example.com
id:       default
password: <PASSWORD>
username: chef-api
```

Or, if no data bag is found, attributes are used

```
default[:f5][:credentials][:default] = {
  host: "lb1.example.com",
  username: "chef-api",
  password: "<PASSWORD>"
}
```

### Resources

In an application's recipe:

```ruby
# Creates the pool if missing and adds this node to the pool
# (currently using node.ipaddress and node.fqdn for the node)
f5_pool 'mypool' do
  host 'value'
  port 'value'
  lb_method 'method' # LB_METHOD_ROUND_ROBIN default
end

# Creates the VIP if missing
f5_vip 'myvip' do
  address 'vipaddress' # IPv4 or FQDN, see below
  port 'vipport'
  protocol 'protocol' # TCP default
  pool 'mypool'

  # this is optional; defaults to :manual so won't touch your setting
  #                   unless you specify one of the valid options.
  snat_pool :automap

  # this is optional; defaults to :manual so won't touch your setting
  #                   unless you specify one of the valid options.
  #                   :none disables the firewall_policy,
  #                   anything else is a named firewall_policy
  enforced_firewall_policy

  # this is optional; defaults to :manual so won't touch your setting
  #                   unless you specify one of the valid options.
  #                   :none disables the firewall_policy,
  #                   anything else is a named firewall_policy
  staged_firewall_policy
  
  # this is optional; If this VIP has IRules on the F5, this resource
  #                   will remove them and insert exactly what is specified
  #                   here. The attribute takes in an array of irules. The order 
  #                   describes the priority of the irules.
  #                   When changing priority of IRules, be aware that the F5
  #                   doesn't provide an API for re-ordering associations therefore
  #                   the re-ordered rules must be deleted then re-added in the correct
  #                   order.
  irules %w(test-irule test-irule-2)
  
  # this is optional; Sets the http profile of the VIP. The default value is `nil`.
  #                   When value is `nil` it will not modify the http profile. Setting  
  #                   to `:none` will remove the http profile. Otherwise
  #                   it sets the http profile. Note, the HTTP Profile must already
  #                   exist on the f5.
  http_profile :none
end

# Create a F5 monitor template
f5_monitor 'test-monitor' do 
  # Required properties
  template_type 'TTYPE_HTTP' # F5 template type
  parent_template 'http'
  interval 5 # frequency to check in seconds
{'fraction_non_alphanumeric': 0.06831022085259374, 'fraction_numerical': 0.00847457627118644, 'mean_word_length': 2.6194237918215615, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2574935', 'n_tokens_mistral': 2276, 'n_tokens_neox': 2122, 'n_words': 1009}