Skip to content

kuty22/TI_Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TI Generator

summary:

Description

This project aims to automate the creation of TestInfra scripts. It tests the files permissions and the listening ports. More options will be added along the time. You can easily run it on your Production environment to fix configuration.
Version 0.3.0

python requirement:

  • xwlt
  • csv
  • pandas
  • argparse-graph

Use it

The generator is located in the role ti.generator, you have to set some targets file with the variable TI_HOST_CONF.

minimal playbook example:
playbook.yml:

- hosts: v1
  vars:
  TI_HOST_CONF:
    - name: Fix prod #  configuration name
      file_name: testinfra-v1.py # test file generated nane
      file_path: ti_result/ # folder where the test file will be write on you host
      export_csv: false
      export_xls: true
      ti_generator_target_file: # file target for generate test file
        - /home/user_test1/
      ti_generator_target_recursive: # folder target with recursivity for generate test file
        - /home/user_test2/
        - /home/user_test3/
      ti_generator_port: True # create test and export for port
 roles:
   - role: ti.generator

result:
ti_result/testinfra-v1.py and ti_result/testinfra-v1-port.py::__

#######################################
# TestInfra generated by Ti-generator #
#######################################
# This tool is an open-source project on Github (https://github.com/kuty22/TI_Generator)


# target: /home/user_test1/
# assert on: ['file_exist', 'user', 'group', mode]
def testinfra_v10(host):
    file_target = host.file('/home/user_test1/')
    assert file_target.user == 'user_test1'
    assert file_target.group == 'user_test1'
    assert file_target.mode == 0o700

# target: /home/user_test2/
# assert on: ['file_exist', 'user', 'group', mode]
def testinfra_v11(host):
    file_target = host.file('/home/user_test2/')
    assert file_target.user == 'user_test2'
    assert file_target.group == 'user_test2'
    assert file_target.mode == 0o700

...
def testinfra_v1_port0_port(host):
    assert host.socket("tcp://*:22").is_listening


def testinfra_v1_port1_port(host):
    assert host.socket("tcp://127.0.0.1:25").is_listening
version description
0.1.0 generate testinfra script for specific file.
0.2.0 recursive folder and export (csv, xls)
0.3.0 generate port tests with export (csv, xls)

About

This project aims to automate the creation of TestInfra scripts. It tests the files permissions for now, and more options will be added along the time. You can easily run it on your Production environment to fix configuration.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages