Jimdo.fastly

ansible-fastly

构建状态 Ansible Galaxy

用于配置 Fastly 服务的 Ansible 模块

安装

$ ansible-galaxy install Jimdo.fastly

文档

模块选项

名称 必需 描述 默认值
name 要创建的服务的唯一名称
fastly_api_key Fastly API 密钥。如果未设置,则使用 FASTLY_API_KEY 环境变量的值。
activate_new_version 配置是否自动激活新创建的版本 true
domains 作为服务入口点的域名列表
backends 为您的域名服务请求的后端列表
cache_settings 缓存设置列表
conditions 条件列表
directors 导向器列表
gzips gzip 配置列表
headers 每个请求要处理的头部列表
healthchecks 用于后端目的的健康检查列表
request_settings 请求设置列表
response_objects 响应对象列表
settings 设置对象
s3s S3 日志记录器列表
syslogs Syslog 日志记录器列表
vcl_snippets VCL 片段列表

后端

Fastly 文档

字段 必需 类型 默认值
name 字符串
port 整数 80
address 字符串
ssl_hostname 字符串
ssl_ca_cert 字符串
ssl_cert_hostname 字符串
shield 字符串
healthcheck 字符串
weight 整数 100
connect_timeout 整数 1000
first_byte_timeout 整数 15000
between_bytes_timeout 整数 10000
error_threshold 整数 0
max_conn 整数 200

缓存设置

Fastly 文档

字段 必需 类型 默认值
name 字符串
action 枚举 ('cache', 'pass', 'restart')
cache_condition 字符串
stale_ttl 整数 0

条件

Fastly 文档

字段 必需 类型 默认值
name 字符串
comment 字符串
priority 整数 0
statement 字符串
type 枚举 ('REQUEST', 'PREFETCH', 'CACHE', 'RESPONSE')

导向器

Fastly 文档

字段 必需 类型 默认值
name 字符串
backends 字符串数组
capacity 整数 100
comment 字符串 ''
quorum 整数 75
shield 字符串
type 整数 (1, 2, 3, 4中的一个) 1
retries 整数 5

头部

Fastly 文档

字段 必需 类型 默认值
name 字符串
action 枚举 ('set', 'append', 'delete', 'regex', 'regex_repeat') set
dst 字符串
ignore_if_set 整数 (0, 1中的一个) 0
priority 整数 100
regex 字符串
request_condition 字符串
response_condition 字符串
cache_condition 字符串
src 字符串
substitution 字符串
type 枚举 ('request', 'fetch', 'cache', 'response')

健康检查

Fastly 文档

字段 必需 类型 默认值
name 字符串
check_interval 整数
comment 字符串 ''
expected_response 整数 200
host 字符串
http_version 字符串 1.1
initial 整数
method 字符串 HEAD
path 字符串 '/'
threshold 整数
timeout 整数
window 整数

请求设置

Fastly 文档

字段 必需 类型 默认值
name 字符串
request_condition 字符串
action 枚举 ('lookup', 'pass')
xff 枚举 ('clear', 'leave', 'append', 'append_all', 'overwrite')
hash_keys 字符串
default_host 字符串
max_stale_age 整数 0
force_miss 整数 0
force_ssl 整数 0
timer_support 整数 0
geo_headers 整数 0
bypass_busy_wait 整数 0

响应对象

Fastly 文档

字段 必需 类型 默认值
name 字符串
request_condition 字符串
response 字符串 Ok
status 整数 200
content 字符串
content_type 字符串

VCL 片段

Fastly 文档

字段 必需 类型 默认值
name 字符串
dynamic 整数 0
type 字符串 "init"
content 字符串
priority 整数 100

S3 日志记录

Fastly 文档

字段 必需 类型 默认值
name 字符串
access_key 字符串
bucket_name 字符串
domain 字符串
format 字符串 %{%Y-%m-%dT%H:%M:%S}t %h "%r" %>s %b
format_version 整数 2
gzip_level 整数 0
message_type 枚举 ('classic', 'loggly', 'logplex', 'blank') classic
path 字符串 /
period 整数 3600
placement 字符串
redundancy 字符串
response_condition 字符串 ''
secret_key 字符串
server_side_encryption_kms_key_id 字符串
server_side_encryption 字符串
timestamp_format 字符串 %Y-%m-%dT%H

Syslog 日志记录

Fastly 文档

字段 必需 类型 默认值
name 字符串
address 字符串
format 字符串 %{%Y-%m-%dT%H:%M:%S}t %h "%r" %>s %b
format_version 整数 2
hostname 字符串
ipv4 字符串
message_type 枚举 ('classic', 'loggly', 'logplex', 'blank') classic
placement 字符串
port 整数
response_condition 字符串 ''
tls_ca_cert 字符串
tls_hostname 字符串
token 字符串
use_tls 整数 0

设置

Fastly 文档

字段 必需 类型 默认值
general.default_ttl 整数 3600

示例

在 Playbook 中使用 fastly_service 模块

---
- hosts: localhost
  connection: local
  gather_facts: False
  roles:
    - Jimdo.fastly
  tasks:
    - fastly_service:
        name: Redirect service
        domains:
          - name: test1.example.net
            comment: redirect domain
        backends:
          - name: localhost
            port: 80
            address: 127.0.0.1
        headers:
          - name: Set Location header
            dst: http.Location
            type: response
            action: set
            src: http://test3.example.net req.url.path
            ignore_if_set: 0
            priority: 10
        response_objects:
          - name: Set 301 status code
            status: 301
$ ansible-playbook -i localhost, fastly.yml

开发

运行测试

FASTLY_API_KEY=some_secret python -m unittest discover tests

更新 VCR 磁带

VCR.py 用于测试中模拟 HTTP 请求。

要更新磁带,只需删除 tests/fixtures/cassettes 目录,然后照常运行测试。您必须使用有效的 Fastly API 密钥才能录制工作。

关于项目

Ansible module for Fastly

安装
ansible-galaxy install Jimdo.fastly
许可证
mit
下载
56.9k
拥有者