faker

ansible-faker - v0.4.0-alpha

Ansible Role Ansible Quality Score Build Status

[working-draft] Faker is a Ansible role that generates fake data already deploy it the server. Inspired on solutions like PHP Faker / Ruby Faker / Perl Data Faker, Python Faker. Initial work from fititnt.syntactic_sugar.

Warning: this is a pre-release. Variable naming conventions may change. Feedback is welcome!


Happy Path example 1: you have do test one server deployed with Ansible but need to create huge amount of data to do stress tests. Ideally ansible-faker should allow (both deterministically and at random), simulate plausible real data. Think of creating 100~10.000 system users, each one with a folder with demo content, each one with an Apache Virtual Host or Nginx Server Block.

Happy Path example 2: while you did not need to do stress test, you need plausible content for some types of deployments (like a CDN) and as such need have several types of content (varying in file extensions, sizes, etc) to discover issues before them happen in production. ansible-faker should allow you be able to do it.

Happy Path example 3: you are a developer of an Ansible role/library/plugin and need to integrate more complex tests on your CI, but doing is so complex that you just don't do it. ansible-faker should allow you to emulate such tests with reasonable performance.




Requirements

None.

This role does not require anything over the averange for an Ansible role.

Role Variables

Public APIs

faker_cdns

Deploy sample content on target paths designed to test a CDN (Content Delivery Network).

List of paths to deploy sample content of files/videos and files/images. Values from Ansible module copy.

    faker_cdns:
      - dest: /home/cdn-site-a/public_html
        owner: cdn-site-a
        group: cdns
      - dest: /home/cdn-site-b/public_html
        owner: cdn-site-b
        group: cdns

faker_groups

Create operational system groups.

List of groups to add/remove. Values from Ansible modules group and win_group

    faker_groups:
      - name: "www-data"
      - name: "haproxy"

faker_static_sites

Deploy sample content of HTML+CSS+JS static website on target paths to be be used as test. The string Hello, world! is granteed to always exist.

List of paths to deploy sample content of files/static-site. Values from Ansible module copy.

faker_php_sites

Deploy sample content of PHP files on target paths to be used to test if PHP is working.

List of paths to deploy sample content of files/php. Values from Ansible module copy.

faker_users

Create operational system users.

List of users to add/remove. Values from Ansible modules user and win_user

    faker_users:
      - name: cdn-site-a
        groups:
          - cdns
      - name: cdn-site-b
        groups:
          - cdns
      - name: site-a
      - name: php-demo
      - name: fititnt
        authorized_key:
          key: https://github.com/fititnt.keys

Special APIs

faker_autoinstall_*

faker_autoinstall_dependencies
  • Default: false

Some Faker public APIs may require packages that already are not automaticaly installed with Ansible. With this option set to true/yes A2S will install for you.

faker_autoinstall_repositories
  • Default: false

Some Faker public APIs may require dependencies that are not available on some versions of operational systems without installation of some external repositories. With this option set to true/yes Faker will autoinstall for you.

faker_default_*

The default values from faker_default_* exist to provide consistence across operational systems and will be used in some places if you did not explicitly provide a value.

faker_default_user
  • Default: root or AdministratorWindows
  • Type: String
  • Example values: root. www-data. nobody

Default user that will be used by Faker on all public APIs when not explicitly specified. Defaults to root or Administrator (based on operational system)

faker_default_group
  • Default: root, wheelBSD, MacOS or AdministratorsWindows
  • Type: String
  • Example values: root. wheel. www-data, www

Default group that will be used by Faker on all public APIs when not explicitly specified. Defautls to root, wheel or Administrators (based on operational system)

faker_default_directory_mode
faker_default_file_mode
faker_iswindows
  • Default: false
  • Type: Bool
  • Example values: true. yes. false, no

Explicitly define that the node is Windows. Defaults to false

Internal variables

For internal variables based on OS, check vars/README.md.

Dependencies

None.

This role does not depend on other Ansible roles. Not even the ap-application-load-balancer.

Example Playbooks

Minimal Playbook

Note: If you run this role without explicitly use any Public APIs (variables started with faker_ that are not defaults) this Ansible role will make no changes on your system.

# Note: this playbook will run without errors, but will not make changes. You
#       need to specify variables
- hosts: all
  roles:
    - { role: fititnt.faker }

Playbook using all Public APIs

- hosts: all
  remote_user: root
  vars:

    faker_groups:
      - name: cdns

    faker_users:
      - name: cdn-site-a
        groups:
          - cdns
      - name: cdn-site-b
        groups:
          - cdns
      - name: site-a
      - name: php-demo
      - name: fititnt
        authorized_key:
          key: https://github.com/fititnt.keys

    # faker_sample_content_static_sites:
    faker_static_sites:
      - dest: /home/site-a/public_html
        owner: site-a
        group: site-a

    # faker_sample_content_cdns:
    faker_cdns:
      - dest: /home/cdn-site-a/public_html
        owner: cdn-site-a
        group: cdns
      - dest: /home/cdn-site-b/public_html
        owner: cdn-site-b
        group: cdns

    # faker_iswindows: true # Uncomment next variable only for Windows hosts.
  roles:
    - { role: fititnt.faker }

Playbook full example with Continuos Integration and testinfra

Check the contents of molecule/default/playbook.yml and our Travis-CI panel at https://travis-ci.com/fititnt/ap-application-load-balancer-extras.

If you are not developing an interface that other people depend on or have a very serius infrastructure or several people making changes, well written Ansible playbooks may already be great. If this is not sufficient, check our testinfra tests file at molecule/default/tests/test_default.py.

TODO

Things that are expected to at some point be implemented or fixed:

  • MVP of faker_apache_virtualhost
  • MVP of faker_nginx_serverblock
  • Ansible Faker is not generating fake data out of the box; it shoud be simpler
    • As v0.4.0-alpha, this role depends of the user to pre-populate the data
    • One issue with this feature is that, different from Faker packages from most programming languages, Ansible Faker very likely would make sense that some variables are reused across different public APIs
      • Feedback on how to design intuitive interface are welcome!
  • Make easy setup to at least one programming language Faker app, so the end users could use it

License

This Ansible role have content from several places with different licenses and authors.

ansible-faker

Public Domain

To the extent possible under law, Emerson Rocha has waived all copyright and related or neighboring rights to this work to Public Domain.

files/static-site

Code licensed MIT, docs CC BY 3.0.

files/static-site/index.html and it's assets are Sample Content from Bootstrap documentation. Source: https://v4-alpha.getbootstrap.com/examples/jumbotron/

About

Faker is a Ansible role that generates fake data for you. Inspired on fzaninotto/Faker. Initial work from ansible-syntactic-sugar.

Install
ansible-galaxy install fititnt/ansible-faker
GitHub repository
License
Unknown
Downloads
25
Owner
Full stack developer from #A11Y to #DevOps at @alligo. Transdisciplinary researcher at @EticaAI: #AIEthics + #AI, #OpenSouce, #OpenScience